#!/bin/sh # Synchronize dunst notification colors and font with active .Xresources/.xth theme. set -eu HOME_DIR="${HOME:-/home/user}" XRES_FILE="${GEMINUX_XRESOURCES:-$HOME_DIR/.Xresources}" if [ ! -r "$XRES_FILE" ] && [ -r /etc/skel/.Xresources ]; then XRES_FILE="/etc/skel/.Xresources" fi if [ -r "$XRES_FILE" ]; then eval "$(awk ' $0 !~ /^[[:space:]]*[!#]/ { idx = index($0, ":") if (idx <= 0) next k = substr($0, 1, idx - 1) v = substr($0, idx + 1) gsub(/^[[:space:]]+|[[:space:]]+$/, "", k) gsub(/^[[:space:]"'\'']+|[[:space:]"'\'']+$/, "", v) if (k == "theme.bgMain" || k == "theme.bgOverlay" || k == "theme.bgHeader" || k == "theme.fgMain" || k == "theme.fgBright" || k == "theme.fgMuted" || k == "theme.accent" || k == "theme.selBg" || k == "theme.border" || k == "theme.danger" || k == "theme.dangerBg" || k == "theme.fontFace" || k == "theme.baseFontSize") { sub(/^theme\./, "", k) gsub(/[^A-Za-z0-9_]/, "_", k) vals[k] = v } } END { for (k in vals) { s = vals[k] gsub(/'\''/, "'\''\\'\'''\''", s) printf "X_%s='\''%s'\''\n", k, s } } ' "$XRES_FILE")" fi BG_MAIN="${X_bgMain:-#0f1419}" BG_OVERLAY="${X_bgOverlay:-${X_bgHeader:-$BG_MAIN}}" FG_MAIN="${X_fgMain:-#e6e1cf}" FG_BRIGHT="${X_fgBright:-$FG_MAIN}" FG_MUTED="${X_fgMuted:-#7b8898}" ACCENT="${X_accent:-${X_selBg:-#59c2ff}}" BORDER="${X_border:-#283444}" DANGER="${X_danger:-#f07178}" DANGER_BG="${X_dangerBg:-#4c1d24}" FONT_FACE="${X_fontFace:-Fira Code}" BASE_SIZE="${X_baseFontSize:-32}" case "$BASE_SIZE" in ''|*[!0-9]*) BASE_SIZE=32 ;; esac PX_SIZE="$(awk -v b="$BASE_SIZE" 'BEGIN { px = int(b + 2) if (px < 30) px = 30 if (px > 44) px = 44 printf "%dpx", px }')" OUT_CONF="${GEMINUX_DUNSTRC:-$HOME_DIR/.config/dunst/dunstrc}" mkdir -p "$(dirname "$OUT_CONF")" cat > "$OUT_CONF.tmp" </dev/null 2>&1; then if pidof dunst >/dev/null 2>&1; then dunstctl reload "$OUT_CONF" >/dev/null 2>&1 || { killall -q dunst 2>/dev/null || true DISPLAY="${DISPLAY:-:0}" dunst -config "$OUT_CONF" >/dev/null 2>&1