#!/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 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" "#0f1419")" BG_OVERLAY="$(get_xres "theme.bgOverlay" "$(get_xres "theme.bgHeader" "$BG_MAIN")")" FG_MAIN="$(get_xres "theme.fgMain" "#e6e1cf")" FG_BRIGHT="$(get_xres "theme.fgBright" "$FG_MAIN")" FG_MUTED="$(get_xres "theme.fgMuted" "#7b8898")" ACCENT="$(get_xres "theme.accent" "$(get_xres "theme.selBg" "#59c2ff")")" BORDER="$(get_xres "theme.border" "#283444")" DANGER="$(get_xres "theme.danger" "#f07178")" DANGER_BG="$(get_xres "theme.dangerBg" "#4c1d24")" FONT_FACE="$(get_xres "theme.fontFace" "Fira Code")" BASE_SIZE="$(get_xres "theme.baseFontSize" "22")" case "$BASE_SIZE" in ''|*[!0-9]*) BASE_SIZE=22 ;; esac PT_SIZE="$(awk -v b="$BASE_SIZE" 'BEGIN { pt = b * 0.55 if (pt < 9.0) pt = 9.0 if (pt > 16.0) pt = 16.0 printf "%.1f", pt }')" 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" 2>/dev/null || { killall -q dunst 2>/dev/null || true DISPLAY="${DISPLAY:-:0}" dunst -config "$OUT_CONF" >/dev/null 2>&1