#!/bin/sh # SPDX-License-Identifier: GPL-2.0-only # Synchronizes dunst notification colors and font with the active NeoUI .xth/.Xresources theme. exec 9>/tmp/bananarchy_sync_dunst.lock flock -w 2 9 2>/dev/null || exit 0 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 if ! pidof -s superd >/dev/null 2>&1; then sleep 0.1 if ! pidof -s dunst >/dev/null 2>&1; then DISPLAY="${DISPLAY:-:0}" dunst -config /tmp/dunstrc >/dev/null 2>&1