aboutsummaryrefslogtreecommitdiffstats
path: root/bin/udt-grub
diff options
context:
space:
mode:
Diffstat (limited to 'bin/udt-grub')
-rwxr-xr-xbin/udt-grub50
1 files changed, 50 insertions, 0 deletions
diff --git a/bin/udt-grub b/bin/udt-grub
new file mode 100755
index 0000000..20fd296
--- /dev/null
+++ b/bin/udt-grub
@@ -0,0 +1,50 @@
+#!/bin/bash
+# udt-grub: rebuild the GRUB theme and say what root has to copy into /boot.
+# Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+# Licensed under the GNU General Public License v2 only.
+#
+# Built, not installed: GRUB reads /boot before /home is mounted, so the theme
+# is a root-owned copy of grub-theme-udt's dist/udt/, and this script only
+# prints the command that refreshes it. Its background is a snapshot of the
+# wallpaper and its colours come from the scheme, so both a wallpaper change
+# and a scheme switch leave the copy stale.
+#
+# udt-accent starts this detached on every run; install.sh runs it in the
+# foreground. A notification goes out only when an installed theme is stale:
+# a machine that never installed it has nothing to refresh.
+
+repo="$(dirname "$(readlink -f "$0")")/.."
+grub_repo="$(realpath -m "$repo/../grub-theme-udt")"
+[ -x "$grub_repo/build" ] || exit 0
+
+# install.sh runs udt-accent, which starts this detached, and then runs this
+# itself. build swaps dist/udt/ in with a rename, so two at once can collide.
+mkdir -p "$grub_repo/dist"
+exec 9>"$grub_repo/dist/.lock"
+flock 9
+
+"$grub_repo/build" >/dev/null || { echo "grub: its build failed, theme not refreshed" >&2; exit 1; }
+
+theme=/boot/grub/themes/udt
+copy="rm -rf $theme && cp -r \"$grub_repo/dist/udt\" /boot/grub/themes/"
+
+if diff -rq "$grub_repo/dist/udt" "$theme" >/dev/null 2>&1; then
+ echo "grub theme: up to date"
+elif [ -d "$theme" ]; then
+ echo "grub theme: refresh as root"
+ echo " $copy"
+ command -v notify-send >/dev/null 2>&1 &&
+ notify-send -a udt "grub: theme rebuilt" "As root:
+$copy"
+else
+ echo "grub theme: run these as root to install it"
+ echo " $copy"
+fi
+grep -q "^GRUB_THEME=\"$theme/theme.txt\"" /etc/default/grub 2>/dev/null || {
+ echo " # once: GRUB_THEME=\"$theme/theme.txt\" in /etc/default/grub, then"
+ echo " grub-mkconfig -o /boot/grub/grub.cfg"
+}
+# The panel title falls back to the OS name until one is set.
+[ -n "$("$repo/bin/udt-machine-name")" ] ||
+ echo " # optional, the panel title: sudo \"$repo/bin/udt-machine-name\" \"My Machine\""
+exit 0