notification service initial

This commit is contained in:
2026-10-26 10:49:54 -06:00
parent c27354df20
commit 4593082c4a
8 changed files with 133 additions and 3 deletions
+29 -2
View File
@@ -6,6 +6,9 @@
# the local checkout is on, plus the short hash to tell same-day commits apart,
# e.g. 2026.10.22 (c5f0651). The kernel is shown separately because it comes
# from Arch, not CoreDesktop.
#
# version --check prints the newer version and exits 0 if one is available,
# exits 1 if this machine is up to date, or 2 if it couldn't check.
COREDESKTOP="$HOME/.local/share/coredesktop"
@@ -13,16 +16,40 @@ source "$COREDESKTOP/utils.sh"
if ! git -C "$COREDESKTOP" rev-parse --git-dir &> /dev/null; then
echo "CoreDesktop isn't installed in $COREDESKTOP."
exit 1
exit 2
fi
version="$(git -C "$COREDESKTOP" log -1 --format='%cd (%h)' --date=format:%Y.%m.%d)"
# Version string for a commit, e.g. 2026.10.22 (c5f0651)
describe() {
git -C "$COREDESKTOP" log -1 --format='%cd (%h)' --date=format:%Y.%m.%d "$1"
}
# Print the newer version if the remote has commits this checkout doesn't.
# Returns 1 if up to date, 2 if the remote couldn't be reached.
newer_version() {
GIT_TERMINAL_PROMPT=0 timeout 30 git -C "$COREDESKTOP" fetch --quiet &> /dev/null || return 2
local behind
behind="$(git -C "$COREDESKTOP" rev-list --count 'HEAD..@{upstream}' 2> /dev/null)" || return 2
(( behind > 0 )) || return 1
describe '@{upstream}'
}
if [ "$1" = "--check" ]; then
newer_version
exit
fi
version="$(describe HEAD)"
# Local edits to the checkout mean this isn't exactly the version above
if [ -n "$(git -C "$COREDESKTOP" status --porcelain --untracked-files=no)" ]; then
version="$version, modified"
fi
if latest="$(newer_version)"; then
version="$version, $latest is available (run update)"
fi
kernel="$(uname -r)"
# If the running kernel's modules are gone, a newer kernel was installed
if [ ! -d "/usr/lib/modules/$kernel" ]; then