2026-11-22 10:49:59 +02:00
|
|
|
#!/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")"
|
|
|
|
|
|
2026-11-22 15:49:38 +02:00
|
|
|
BASE_SIZE="$(get_xres "theme.baseFontSize" "32")"
|
2026-11-22 10:49:59 +02:00
|
|
|
case "$BASE_SIZE" in
|
2026-11-22 15:49:38 +02:00
|
|
|
''|*[!0-9]*) BASE_SIZE=32 ;;
|
2026-11-22 10:49:59 +02:00
|
|
|
esac
|
2026-11-22 15:49:38 +02:00
|
|
|
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
|
2026-11-22 10:49:59 +02:00
|
|
|
}')"
|
|
|
|
|
|
|
|
|
|
OUT_CONF="${GEMINUX_DUNSTRC:-$HOME_DIR/.config/dunst/dunstrc}"
|
|
|
|
|
mkdir -p "$(dirname "$OUT_CONF")"
|
|
|
|
|
|
|
|
|
|
cat > "$OUT_CONF.tmp" <<EOF
|
|
|
|
|
# Auto-generated by geminux-sync-dunst-theme from active .Xresources theme
|
|
|
|
|
[global]
|
|
|
|
|
monitor = 0
|
|
|
|
|
follow = mouse
|
2026-11-22 15:49:38 +02:00
|
|
|
width = 720
|
|
|
|
|
height = (0, 360)
|
2026-11-24 11:05:18 +02:00
|
|
|
origin = top-center
|
|
|
|
|
offset = (0, 96)
|
2026-11-22 10:49:59 +02:00
|
|
|
notification_limit = 5
|
|
|
|
|
progress_bar = true
|
2026-11-24 11:05:18 +02:00
|
|
|
progress_bar_height = 18
|
|
|
|
|
progress_bar_frame_width = 2
|
|
|
|
|
progress_bar_min_width = 560
|
|
|
|
|
progress_bar_max_width = 660
|
2026-11-22 15:49:38 +02:00
|
|
|
padding = 18
|
|
|
|
|
horizontal_padding = 22
|
|
|
|
|
text_icon_padding = 16
|
|
|
|
|
frame_width = 3
|
2026-11-22 10:49:59 +02:00
|
|
|
frame_color = "$ACCENT"
|
|
|
|
|
separator_color = "$BORDER"
|
2026-11-24 11:05:18 +02:00
|
|
|
corner_radius = 0
|
2026-11-22 10:49:59 +02:00
|
|
|
idle_threshold = 120
|
2026-11-22 15:49:38 +02:00
|
|
|
font = $FONT_FACE $PX_SIZE
|
2026-11-22 10:49:59 +02:00
|
|
|
markup = full
|
|
|
|
|
format = "<b>%s</b>\n%b"
|
|
|
|
|
alignment = left
|
|
|
|
|
vertical_alignment = center
|
|
|
|
|
show_age_threshold = 60
|
|
|
|
|
word_wrap = yes
|
|
|
|
|
icon_position = left
|
2026-11-22 15:49:38 +02:00
|
|
|
max_icon_size = 64
|
2026-11-22 10:49:59 +02:00
|
|
|
dmenu = /usr/bin/dmenu -p dunst:
|
|
|
|
|
mouse_left_click = do_action, close_current
|
|
|
|
|
mouse_middle_click = close_current
|
|
|
|
|
mouse_right_click = close_all
|
|
|
|
|
|
|
|
|
|
[urgency_low]
|
|
|
|
|
background = "$BG_MAIN"
|
|
|
|
|
foreground = "$FG_MUTED"
|
|
|
|
|
frame_color = "$BORDER"
|
|
|
|
|
timeout = 5
|
|
|
|
|
|
|
|
|
|
[urgency_normal]
|
|
|
|
|
background = "$BG_OVERLAY"
|
|
|
|
|
foreground = "$FG_MAIN"
|
|
|
|
|
frame_color = "$ACCENT"
|
|
|
|
|
timeout = 8
|
|
|
|
|
|
|
|
|
|
[urgency_critical]
|
|
|
|
|
background = "$DANGER_BG"
|
|
|
|
|
foreground = "$FG_BRIGHT"
|
|
|
|
|
frame_color = "$DANGER"
|
|
|
|
|
timeout = 0
|
2026-11-24 11:05:18 +02:00
|
|
|
|
|
|
|
|
[osd]
|
|
|
|
|
appname = "geminux-osd"
|
|
|
|
|
alignment = center
|
|
|
|
|
background = "$BG_OVERLAY"
|
|
|
|
|
foreground = "$FG_BRIGHT"
|
|
|
|
|
highlight = "$ACCENT"
|
|
|
|
|
frame_color = "$ACCENT"
|
|
|
|
|
history_ignore = yes
|
|
|
|
|
|
|
|
|
|
[osd_single]
|
|
|
|
|
appname = "geminux-osd"
|
|
|
|
|
body = ""
|
|
|
|
|
format = "<b>%s</b>"
|
2026-11-22 10:49:59 +02:00
|
|
|
EOF
|
|
|
|
|
mv -f "$OUT_CONF.tmp" "$OUT_CONF"
|
|
|
|
|
|
|
|
|
|
if [ "${1:-}" != "--no-restart" ] && command -v dunstctl >/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 </dev/null &
|
|
|
|
|
}
|
|
|
|
|
fi
|
|
|
|
|
fi
|