aboutsummaryrefslogtreecommitdiffstats
path: root/bin/udt-homepage
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-23 12:46:07 +0200
committerDanilo M. <danix@danix.xyz>2026-09-23 12:46:07 +0200
commit041edc485cd81b2c564cbcaa3eb425c9ed5520e4 (patch)
treea0b8b8c2cb52db5b1862151577a3640c75cd40e8 /bin/udt-homepage
parent47dcb72c48e165154ef344588eed178c481a535c (diff)
downloadunified-desktop-theme-041edc485cd81b2c564cbcaa3eb425c9ed5520e4.tar.gz
unified-desktop-theme-041edc485cd81b2c564cbcaa3eb425c9ed5520e4.zip
feat: stage the wallpaper on homepage and notify on completion
bin/udt-homepage replaces install.sh's inline scp. It stages custom.css and the current wallpaper, keeping the wallpaper's own extension, then raises a desktop notification with the root commands that install both and point settings.yaml at the new background. Plain root commands, not sudo: the login user on that host has no sudo rights. udt-accent starts it detached on every run, so it follows a wallpaper change (wallp) as well as a scheme switch (install.sh) without holding either up when the host is unreachable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'bin/udt-homepage')
-rwxr-xr-xbin/udt-homepage53
1 files changed, 53 insertions, 0 deletions
diff --git a/bin/udt-homepage b/bin/udt-homepage
new file mode 100755
index 0000000..7be5d16
--- /dev/null
+++ b/bin/udt-homepage
@@ -0,0 +1,53 @@
+#!/bin/bash
+# udt-homepage: stage the homepage stylesheet and wallpaper on the dashboard host.
+# Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+# Licensed under the GNU General Public License v2 only.
+#
+# Staged, not installed: /opt/homepage is root-owned and this script does not
+# hold root there, so it copies into ~/hp-stage/ and a notification carries
+# the command that finishes the job.
+#
+# udt-accent starts this detached on every run, which covers both a wallpaper
+# change (wallp) and a scheme switch (install.sh). Never slow and never loud
+# when the host is away: a laptop off that network gets a short connect
+# timeout and no notification, since there is nothing for the user to do.
+
+repo="$(dirname "$(readlink -f "$0")")/.."
+css="$repo/templates/homepage/custom.css"
+wall="$HOME/.cache/udt/wpaper"
+opts=(-q -o ConnectTimeout=5 -o BatchMode=yes)
+
+[ -f "$css" ] && [ -e "$wall" ] || exit 0
+
+# The wallpaper keeps its own extension, so settings.yaml has to follow it: the
+# finish command rewrites its background.image line to match. The extension
+# ends up in a command the user runs as root, so only known image types pass.
+real="$(readlink -f "$wall")"
+ext="${real##*.}"
+ext="${ext,,}"
+case "$ext" in
+ png|jpg|jpeg|webp|gif|avif) ;;
+ *) echo "homepage: $real is not a known image type, skipped" >&2; exit 1 ;;
+esac
+bg="background.$ext"
+
+scp "${opts[@]}" "$css" homepage:hp-stage/custom.css &&
+ scp "${opts[@]}" "$real" "homepage:hp-stage/$bg" || {
+ echo "homepage: unreachable, skipped" >&2
+ exit 1
+}
+
+# Root commands, not sudo: the login user there has no sudo rights. Root's ~
+# is not the staging directory, so it is named through the ssh login user,
+# which ssh -G resolves from the config without connecting.
+stage="~$(ssh -G homepage 2>/dev/null | awk '/^user /{print $2}')/hp-stage"
+finish="cp $stage/custom.css /opt/homepage/config/
+cp $stage/$bg /opt/homepage/public/images/
+sed -i 's|/images/background\.[a-z]*|/images/$bg|' /opt/homepage/config/settings.yaml
+systemctl restart homepage"
+echo "homepage: staged, finish as root on homepage:"
+echo "$finish"
+command -v notify-send >/dev/null 2>&1 &&
+ notify-send -a udt "homepage: theme staged" "As root on homepage:
+$finish"
+exit 0