aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/udt-accent9
-rwxr-xr-xbin/udt-grub50
2 files changed, 56 insertions, 3 deletions
diff --git a/bin/udt-accent b/bin/udt-accent
index 72d3a64..1027fab 100755
--- a/bin/udt-accent
+++ b/bin/udt-accent
@@ -477,9 +477,12 @@ def main(image):
# The dashboard host. Detached, because wallp runs this synchronously and
# an unreachable host would hold the wallpaper change for the scp timeout.
- subprocess.Popen([Path(__file__).resolve().parent / "udt-homepage"],
- stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL, start_new_session=True)
+ # GRUB's background is a wallpaper snapshot. Detached for the same reason;
+ # it only rebuilds and notifies, since the copy into /boot needs root.
+ for helper in ("udt-homepage", "udt-grub"):
+ subprocess.Popen([Path(__file__).resolve().parent / helper],
+ stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
+ stderr=subprocess.DEVNULL, start_new_session=True)
before, after = hue_neighbours(name)
print(f"{name} {ACCENTS[name]} (border: {before} .. {name} .. {after})")
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