From 80ec989b5031e4c06f167735fa1132018d6c2bcb Mon Sep 17 00:00:00 2001 From: Luxferre Date: Fri, 30 Oct 2026 19:28:17 +0200 Subject: [PATCH] Synchronize dunst notification manager colors and font with active NeoUI theme --- .../usr/bin/bananarchy-sync-dunst-theme | 130 ++++++++++++++++++ .../usr/share/superd/services/dunst.service | 7 + .../sxmo/default_hooks/sxmo_hook_start.sh | 1 + 3 files changed, 138 insertions(+) create mode 100755 overlay/rootfs/usr/bin/bananarchy-sync-dunst-theme create mode 100644 overlay/rootfs/usr/share/superd/services/dunst.service diff --git a/overlay/rootfs/usr/bin/bananarchy-sync-dunst-theme b/overlay/rootfs/usr/bin/bananarchy-sync-dunst-theme new file mode 100755 index 0000000..28113bb --- /dev/null +++ b/overlay/rootfs/usr/bin/bananarchy-sync-dunst-theme @@ -0,0 +1,130 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-only +# Synchronizes dunst notification colors and font with the active NeoUI .xth/.Xresources theme. + +XRES_FILE="/home/user/.Xresources" +if [ -e /tmp/bananarchy_duress_mode ] && [ -r /tmp/duress_home/.Xresources ]; then + XRES_FILE="/tmp/duress_home/.Xresources" +elif [ ! -r "$XRES_FILE" ] && [ -r /usr/share/sxmo/appcfg/Xresources ]; then + XRES_FILE="/usr/share/sxmo/appcfg/Xresources" +fi + +get_xres() { + key="$1" + def="$2" + if [ -r "$XRES_FILE" ]; then + val="$(awk -F: -v k="$key" ' + $0 !~ /^[[:space:]]*[!#]/ { + kpart = $1 + gsub(/^[[:space:]]+|[[:space:]]+$/, "", kpart) + if (kpart == k) { + sub(/^[^:]*:[[:space:]]*/, "", $0) + gsub(/^[[:space:]"'\'']+|[[:space:]"'\'']+$/, "", $0) + print $0 + } + } + ' "$XRES_FILE" | tail -n 1)" + if [ -n "$val" ]; then + printf '%s' "$val" + return + fi + fi + printf '%s' "$def" +} + +BG_MAIN="$(get_xres "theme.bgMain" "")" +[ -z "$BG_MAIN" ] && BG_MAIN="$(get_xres "*background" "#1c1f26")" + +BG_OVERLAY="$(get_xres "theme.bgOverlay" "")" +[ -z "$BG_OVERLAY" ] && BG_OVERLAY="$(get_xres "theme.bgHeader" "$BG_MAIN")" + +FG_MAIN="$(get_xres "theme.fgMain" "")" +[ -z "$FG_MAIN" ] && FG_MAIN="$(get_xres "*foreground" "#eceff4")" + +FG_BRIGHT="$(get_xres "theme.fgBright" "$FG_MAIN")" +FG_MUTED="$(get_xres "theme.fgMuted" "#9aa5b4")" + +ACCENT="$(get_xres "theme.accent" "")" +[ -z "$ACCENT" ] && ACCENT="$(get_xres "theme.selBg" "#88c0d0")" + +BORDER="$(get_xres "theme.border" "#4c566a")" +DANGER="$(get_xres "theme.danger" "#bf616a")" +DANGER_BG="$(get_xres "theme.dangerBg" "#4c2228")" + +FONT_FACE="$(get_xres "theme.fontFace" "Fira Code")" +BASE_SIZE="$(get_xres "theme.baseFontSize" "13")" +case "$BASE_SIZE" in + ''|*[!0-9]*) BASE_SIZE=13 ;; +esac +PT_SIZE="$(awk -v b="$BASE_SIZE" 'BEGIN { + pt = b * 0.72 + if (pt < 8.0) pt = 8.0 + if (pt > 14.0) pt = 14.0 + printf "%.1f", pt +}')" + +write_dunstrc() { + target="$1" + cat > "$target" </dev/null || true + cp -f /tmp/dunstrc /home/user/.config/dunst/dunstrc 2>/dev/null || true +else + mkdir -p /tmp/duress_home/.config/dunst 2>/dev/null || true + cp -f /tmp/dunstrc /tmp/duress_home/.config/dunst/dunstrc 2>/dev/null || true +fi + +if [ "${1:-}" != "--no-restart" ]; then + if pidof -s dunst >/dev/null 2>&1; then + pkill -x dunst >/dev/null 2>&1 || true + sleep 0.08 + if ! pidof -s dunst >/dev/null 2>&1; then + DISPLAY="${DISPLAY:-:0}" dunst -config /tmp/dunstrc >/dev/null 2>&1 /dev/null 2>&1 || true superctl start dunst # start adaptive brightness at boot