#!/bin/sh # ANODE Dunst notification theme & DPI scaler (strict POSIX sh) set -eu : "${XDG_CONFIG_HOME:=$HOME/.config}" XRES="${1:-$HOME/.Xresources}" DUNST_DIR="$XDG_CONFIG_HOME/dunst" DUNST_RC="$DUNST_DIR/dunstrc" xres_get() { _k="$1" _def="$2" _val="$(awk -v key="$_k" ' { s = $0 gsub(/^[ \t\r]+|[ \t\r]+$/, "", s) if (s == "" || substr(s, 1, 1) == "!" || substr(s, 1, 1) == "#") next p = index(s, ":") if (p > 0) { k = substr(s, 1, p - 1) gsub(/^[ \t]+|[ \t]+$/, "", k) if (k == key) { v = substr(s, p + 1) gsub(/^[ \t]+|[ \t]+$/, "", v) print v exit } } } ' "$XRES" 2>/dev/null || true)" if [ -n "$_val" ]; then printf '%s\n' "$_val" else printf '%s\n' "$_def" fi } if [ ! -r "$XRES" ]; then exit 0 fi FONT_FACE="$(xres_get theme.fontFace "Fira Code")" SCALE="$(xres_get theme.scale "1.00")" BASE_SZ="$(xres_get theme.baseFontSize "15")" BG_OVERLAY="$(xres_get theme.bgOverlay "#192231")" BG_URGENT="$(xres_get theme.dangerBg "#471d24")" FG_BRIGHT="$(xres_get theme.fgBright "#ffffff")" FG_MAIN="$(xres_get theme.fgMain "#e6e1cf")" BORDER="$(xres_get theme.border "#283444")" ACCENT="$(xres_get theme.accent "#59c2ff")" WARNING="$(xres_get theme.warning "#ffb454")" DANGER="$(xres_get theme.danger "#f07178")" GEOM="$(awk -v s="$SCALE" -v bsz="$BASE_SZ" 'BEGIN { sc = s + 0.0 if (sc < 0.50) sc = 0.50 if (sc > 4.00) sc = 4.00 w = int(320.0 * sc + 0.5); if (w < 220) w = 220 hmax = int(160.0 * sc + 0.5); if (hmax < 80) hmax = 80 ox = int(14.0 * sc + 0.5); if (ox < 8) ox = 8 oy = int(38.0 * sc + 0.5); if (oy < 20) oy = 20 pad = int(10.0 * sc + 0.5); if (pad < 6) pad = 6 hpad = int(12.0 * sc + 0.5); if (hpad < 8) hpad = 8 tpad = int(8.0 * sc + 0.5); if (tpad < 4) tpad = 4 fw = int(2.0 * sc + 0.5); if (fw < 1) fw = 1 rad = int(6.0 * sc + 0.5); if (rad < 3) rad = 3 pbar_h = int(6.0 * sc + 0.5); if (pbar_h < 4) pbar_h = 4 fpx = int((bsz + 0.0) + 0.5); if (fpx < 10) fpx = 10; if (fpx > 72) fpx = 72 printf "%d %d %d %d %d %d %d %d %d %d %d\n", w, hmax, ox, oy, pad, hpad, tpad, fw, rad, pbar_h, fpx }')" set -- $GEOM D_W="$1" D_H="$2" D_OX="$3" D_OY="$4" D_PAD="$5" D_HPAD="$6" D_TPAD="$7" D_FW="$8" D_RAD="$9" shift 9 D_PBAR="$1" D_FPX="$2" mkdir -p "$DUNST_DIR" TMP_RC="$DUNST_RC.tmp.$$" cat > "$TMP_RC" </dev/null 2>&1; then dunstctl reload >/dev/null 2>&1 || true fi _dpids="$( (ps -eo pid=,comm= 2>/dev/null || ps -ax -o pid=,comm= 2>/dev/null || true) | awk ' { cmd=$2; sub(/^.*\//, "", cmd); if (cmd == "dunst") print $1 } ' )" if [ -n "${_dpids:-}" ]; then for _p in $_dpids; do kill -HUP "$_p" 2>/dev/null || true done fi fi