feat(theme,display,wm,power,make): add Anodized theme, editors, multi-monitor arrangement, power timeouts, bar compaction, and replace state preservation
- Replace deprecated AnodeDefault with dark-silvery Anodized default theme - Add interactive theme editor, duplicator, and non-standard .xth importer to anode-themes (+ CLI --install) - Fix multi-monitor dwm/lock/vkbd/EDID edge cases and integrate monitor arrangement + 15s revert into anode-display and anode-apply-display - Gate anode-touchd behind WITH_TOUCHD=1 (keeping anode-vkbd unconditional) and add help/rebuild/install-touch/install-system targets to Makefile - Add idle screen dim, lock, suspend, and suspend-on-AC timeout controls to anode-power and anode-display backed by power.conf + SIGUSR1 - Prevent lockscreen subtitle overflow and progressively compact status bar segments so focused window titles remain visible - Preserve workspaces, active desktop, monitor state, floating/fullscreen states, and focus across anode-replace and restarts
This commit is contained in:
1 parent
bb81541b42
commit
4ec3f59e02
40 files changed
+5843
-768
No files matched your search
Executable
+125
@@ -0,0 +1,125 @@
|
||||
#!/bin/sh
|
||||
# ANODE multi-monitor saved layout restorer (strict POSIX sh)
|
||||
set -eu
|
||||
|
||||
: "${XDG_CONFIG_HOME:=$HOME/.config}"
|
||||
CONF_FILE="$XDG_CONFIG_HOME/anode/displays.conf"
|
||||
|
||||
if [ -z "${DISPLAY:-}" ] || [ ! -r "$CONF_FILE" ] || ! command -v xrandr >/dev/null 2>&1; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
XR_OUT="$(xrandr --query 2>/dev/null || true)"
|
||||
if [ -z "$XR_OUT" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SIG="$(printf '%s\n' "$XR_OUT" | awk '/ connected/ { print $1 }' | LC_ALL=C sort | awk '
|
||||
{ s = (NR == 1) ? $0 : (s "," $0) }
|
||||
END { print s }
|
||||
')"
|
||||
if [ -z "$SIG" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
XR_SPEC="$(printf '%s\n' "$XR_OUT" | awk -v conf="$CONF_FILE" -v sig="$SIG" '
|
||||
BEGIN {
|
||||
cur_out = ""
|
||||
}
|
||||
/^[A-Za-z0-9._-]+ (connected|disconnected)/ {
|
||||
cur_out = ""
|
||||
if ($2 == "connected") {
|
||||
cur_out = $1
|
||||
conn[cur_out] = 1
|
||||
}
|
||||
next
|
||||
}
|
||||
cur_out != "" && /^[[:space:]]+[0-9]+x[0-9]+/ {
|
||||
mode = $1
|
||||
modes[cur_out SUBSEP mode] = 1
|
||||
next
|
||||
}
|
||||
END {
|
||||
hdr = "[profile:" sig "]"
|
||||
in_sec = 0
|
||||
en_cnt = 0
|
||||
out_cnt = 0
|
||||
while ((getline line < conf) > 0) {
|
||||
gsub(/\r$/, "", line)
|
||||
s = line
|
||||
gsub(/^[ \t]+|[ \t]+$/, "", s)
|
||||
if (s == "" || substr(s, 1, 1) == "#" || substr(s, 1, 1) == ";") continue
|
||||
if (substr(s, 1, 1) == "[") {
|
||||
if (in_sec) break
|
||||
in_sec = (s == hdr)
|
||||
continue
|
||||
}
|
||||
if (!in_sec || substr(s, 1, 7) != "output=") continue
|
||||
n = split(substr(s, 8), f, ",")
|
||||
if (n < 8) continue
|
||||
name = f[1]; en = f[2]; pri = f[3]; mode = f[4]
|
||||
hz = f[5]; px = f[6]; py = f[7]; rot = f[8]
|
||||
if (name !~ /^[A-Za-z0-9._-]+$/ || !(name in conn)) continue
|
||||
if (en != "0" && en != "1") continue
|
||||
if (pri != "0" && pri != "1") continue
|
||||
if (px !~ /^-?[0-9]+$/ || py !~ /^-?[0-9]+$/) continue
|
||||
if (rot != "normal" && rot != "left" && rot != "inverted" && rot != "right") continue
|
||||
|
||||
if (en == "0") {
|
||||
rows[++out_cnt] = name "|0|0|-|-|0|0|normal"
|
||||
continue
|
||||
}
|
||||
has_mode = (mode ~ /^[0-9]+x[0-9]+$/ && ((name SUBSEP mode) in modes))
|
||||
if (!has_mode) mode = "auto"
|
||||
if (hz !~ /^[0-9]+(\.[0-9]+)?$/) hz = ""
|
||||
rows[++out_cnt] = name "|1|" pri "|" mode "|" hz "|" px "|" py "|" rot
|
||||
en_cnt++
|
||||
}
|
||||
close(conf)
|
||||
if (en_cnt < 1) exit 0
|
||||
for (i = 1; i <= out_cnt; i++) {
|
||||
print rows[i]
|
||||
}
|
||||
}
|
||||
')"
|
||||
|
||||
if [ -z "$XR_SPEC" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
set --
|
||||
OLD_IFS="$IFS"
|
||||
IFS='
|
||||
'
|
||||
for row in $XR_SPEC; do
|
||||
_name="${row%%|*}"; _rest="${row#*|}"
|
||||
_en="${_rest%%|*}"; _rest="${_rest#*|}"
|
||||
_pri="${_rest%%|*}"; _rest="${_rest#*|}"
|
||||
_mode="${_rest%%|*}"; _rest="${_rest#*|}"
|
||||
_hz="${_rest%%|*}"; _rest="${_rest#*|}"
|
||||
_px="${_rest%%|*}"; _rest="${_rest#*|}"
|
||||
_py="${_rest%%|*}"; _rot="${_rest#*|}"
|
||||
|
||||
set -- "$@" "--output" "$_name"
|
||||
if [ "$_en" = "0" ]; then
|
||||
set -- "$@" "--off"
|
||||
continue
|
||||
fi
|
||||
if [ "$_mode" = "auto" ]; then
|
||||
set -- "$@" "--auto"
|
||||
else
|
||||
set -- "$@" "--mode" "$_mode"
|
||||
if [ -n "$_hz" ] && [ "$_hz" != "-" ]; then
|
||||
set -- "$@" "--rate" "$_hz"
|
||||
fi
|
||||
fi
|
||||
set -- "$@" "--pos" "${_px}x${_py}" "--rotate" "$_rot"
|
||||
if [ "$_pri" = "1" ]; then
|
||||
set -- "$@" "--primary"
|
||||
fi
|
||||
done
|
||||
IFS="$OLD_IFS"
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
xrandr "$@" >/dev/null 2>&1 || true
|
||||
fi
|
||||
@@ -73,9 +73,7 @@ detect_edid_scale() {
|
||||
if [ "$_dpi" = "96" ] && [ -n "${DISPLAY:-}" ] && command -v xrandr >/dev/null 2>&1; then
|
||||
_xrandr_dpi="$(xrandr --query 2>/dev/null | awk '
|
||||
/ connected/ {
|
||||
if (match($0, /[0-9]+x[0-9]+/) && match($0, /[0-9]+mm x [0-9]+mm/)) {
|
||||
res = substr($0, RSTART)
|
||||
}
|
||||
is_pri = ($0 ~ / primary /)
|
||||
px = 0; wmm = 0
|
||||
for (i = 1; i <= NF; i++) {
|
||||
if ($i ~ /^[0-9]+x[0-9]+(\+[0-9]+\+[0-9]+)?$/ && px == 0) {
|
||||
@@ -86,10 +84,19 @@ detect_edid_scale() {
|
||||
}
|
||||
}
|
||||
if (px > 0 && wmm > 0) {
|
||||
printf "%.2f\n", (px * 25.4) / wmm
|
||||
exit
|
||||
val = (px * 25.4) / wmm
|
||||
if (is_pri) {
|
||||
printf "%.2f\n", val
|
||||
got = 1
|
||||
exit
|
||||
} else if (fallback == "") {
|
||||
fallback = sprintf("%.2f", val)
|
||||
}
|
||||
}
|
||||
}
|
||||
END {
|
||||
if (!got && fallback != "") print fallback
|
||||
}
|
||||
' || true)"
|
||||
if [ -n "${_xrandr_dpi:-}" ]; then
|
||||
_dpi="$_xrandr_dpi"
|
||||
|
||||
@@ -11,16 +11,84 @@ SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
|
||||
|
||||
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
|
||||
cat <<'EOF'
|
||||
Usage: anode-apply-theme [THEME_NAME | /path/to/Theme.xth]
|
||||
Usage:
|
||||
anode-apply-theme [THEME_NAME | /path/to/Theme.xth]
|
||||
anode-apply-theme --install /path/to/Theme.xth [Name]
|
||||
EOF
|
||||
exit 0
|
||||
fi
|
||||
|
||||
REQ_THEME="${1:-}"
|
||||
sanitize_theme_name() {
|
||||
printf '%s' "$1" | tr -c 'A-Za-z0-9_-' '_' | sed 's/^_*//; s/_*$//'
|
||||
}
|
||||
|
||||
INSTALL_SRC=""
|
||||
INSTALL_NAME=""
|
||||
REQ_THEME=""
|
||||
if [ "${1:-}" = "--install" ]; then
|
||||
if [ $# -lt 2 ] || [ -z "${2:-}" ]; then
|
||||
printf 'anode-apply-theme: --install requires a .xth file path\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
INSTALL_SRC="$2"
|
||||
INSTALL_NAME="${3:-}"
|
||||
else
|
||||
REQ_THEME="${1:-}"
|
||||
fi
|
||||
|
||||
if [ -n "$INSTALL_SRC" ]; then
|
||||
if [ ! -f "$INSTALL_SRC" ] || [ ! -r "$INSTALL_SRC" ]; then
|
||||
printf 'anode-apply-theme: cannot read theme file: %s\n' "$INSTALL_SRC" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! awk '
|
||||
{
|
||||
s = $0
|
||||
gsub(/^[ \t\r\n]+|[ \t\r\n]+$/, "", s)
|
||||
if (s == "" || substr(s, 1, 1) == "!" || substr(s, 1, 1) == "#") next
|
||||
if (index(s, ":") > 1) { ok = 1; exit }
|
||||
}
|
||||
END { exit(ok ? 0 : 1) }
|
||||
' "$INSTALL_SRC"; then
|
||||
printf 'anode-apply-theme: invalid .xth theme file: %s\n' "$INSTALL_SRC" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$INSTALL_NAME" ]; then
|
||||
INSTALL_NAME="$(awk -F: '/^theme\.name[[:space:]]*:/ { sub(/^[[:space:]]+/, "", $2); sub(/[ \t\r\n]+$/, "", $2); print $2; exit }' "$INSTALL_SRC" || true)"
|
||||
fi
|
||||
if [ -z "$INSTALL_NAME" ]; then
|
||||
INSTALL_NAME="$(basename "$INSTALL_SRC" .xth)"
|
||||
fi
|
||||
SAFE_NAME="$(sanitize_theme_name "$INSTALL_NAME")"
|
||||
if [ -z "$SAFE_NAME" ] || [ "$SAFE_NAME" = "." ] || [ "$SAFE_NAME" = ".." ]; then
|
||||
printf 'anode-apply-theme: invalid target theme name\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$CONF_DIR/themes"
|
||||
DEST_XTH="$CONF_DIR/themes/$SAFE_NAME.xth"
|
||||
TMP_INST="$DEST_XTH.tmp.$$"
|
||||
awk -v tname="$SAFE_NAME" '
|
||||
BEGIN { had_name = 0 }
|
||||
/^theme\.name[[:space:]]*:/ {
|
||||
if (!had_name) {
|
||||
printf "theme.name: %s\n", tname
|
||||
had_name = 1
|
||||
}
|
||||
next
|
||||
}
|
||||
{ print $0 }
|
||||
END {
|
||||
if (!had_name) printf "theme.name: %s\n", tname
|
||||
}
|
||||
' "$INSTALL_SRC" > "$TMP_INST"
|
||||
mv -f "$TMP_INST" "$DEST_XTH"
|
||||
REQ_THEME="$DEST_XTH"
|
||||
fi
|
||||
|
||||
if [ -z "$REQ_THEME" ] && [ -f "$THEME_CONF" ]; then
|
||||
REQ_THEME="$(awk -F= '/^THEME=/{ print $2; exit }' "$THEME_CONF" 2>/dev/null || true)"
|
||||
fi
|
||||
: "${REQ_THEME:=AnodeDefault}"
|
||||
: "${REQ_THEME:=Anodized}"
|
||||
|
||||
find_xth() {
|
||||
_q="$1"
|
||||
@@ -49,6 +117,13 @@ find_xth() {
|
||||
}
|
||||
|
||||
XTH_FILE="$(find_xth "$REQ_THEME" || true)"
|
||||
if [ -z "$XTH_FILE" ] || [ ! -r "$XTH_FILE" ]; then
|
||||
_req_base="$(basename "$REQ_THEME" .xth)"
|
||||
if [ "$_req_base" = "AnodeDefault" ]; then
|
||||
printf 'anode-apply-theme: warning: AnodeDefault is deprecated; using Anodized\n' >&2
|
||||
XTH_FILE="$(find_xth "Anodized" || true)"
|
||||
fi
|
||||
fi
|
||||
if [ -z "$XTH_FILE" ] || [ ! -r "$XTH_FILE" ]; then
|
||||
printf 'anode-apply-theme: theme not found: %s\n' "$REQ_THEME" >&2
|
||||
exit 1
|
||||
|
||||
@@ -94,6 +94,9 @@ for _envfile in "$ANODE_PREFIX/share/anode/env.sh" "$SCRIPT_DIR/../data/env.sh";
|
||||
done
|
||||
unset _envfile
|
||||
|
||||
if [ -n "${DISPLAY:-}" ] && command -v anode-apply-display >/dev/null 2>&1; then
|
||||
anode-apply-display >/dev/null 2>&1 || true
|
||||
fi
|
||||
if [ ! -f "$XDG_CONFIG_HOME/anode/scale.conf" ] && command -v anode-apply-scale >/dev/null 2>&1; then
|
||||
anode-apply-scale auto --no-apply >/dev/null 2>&1 || true
|
||||
fi
|
||||
@@ -114,7 +117,7 @@ if [ "${ANODE_NO_DBUS:-0}" != "1" ]; then
|
||||
fi
|
||||
|
||||
if [ ! -f "$HOME/.Xresources" ] && command -v anode-apply-theme >/dev/null 2>&1; then
|
||||
anode-apply-theme AnodeDefault >/dev/null 2>&1 || true
|
||||
anode-apply-theme Anodized >/dev/null 2>&1 || true
|
||||
elif [ -f "$HOME/.Xresources" ]; then
|
||||
if command -v xrdb >/dev/null 2>&1; then
|
||||
xrdb -merge "$HOME/.Xresources" >/dev/null 2>&1 || true
|
||||
@@ -150,7 +153,9 @@ spawn_bg xsettingsd
|
||||
spawn_bg dunst
|
||||
spawn_bg anode-statusd
|
||||
spawn_bg anode-powerd
|
||||
spawn_bg anode-touchd
|
||||
if [ "${ANODE_NO_TOUCHD:-0}" != "1" ]; then
|
||||
spawn_bg anode-touchd
|
||||
fi
|
||||
|
||||
if [ "${ANODE_TOUCH:-0}" = "1" ]; then
|
||||
spawn_bg anode-vkbd
|
||||
|
||||
@@ -43,14 +43,14 @@ 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")"
|
||||
BG_OVERLAY="$(xres_get theme.bgOverlay "#171b22")"
|
||||
BG_URGENT="$(xres_get theme.dangerBg "#3f1d20")"
|
||||
FG_BRIGHT="$(xres_get theme.fgBright "#f5f7fa")"
|
||||
FG_MAIN="$(xres_get theme.fgMain "#e4e8ee")"
|
||||
BORDER="$(xres_get theme.border "#2d3440")"
|
||||
ACCENT="$(xres_get theme.accent "#cfd6e0")"
|
||||
WARNING="$(xres_get theme.warning "#e2bc72")"
|
||||
DANGER="$(xres_get theme.danger "#e07a7a")"
|
||||
|
||||
GEOM="$(awk -v s="$SCALE" -v bsz="$BASE_SZ" 'BEGIN {
|
||||
sc = s + 0.0
|
||||
|
||||
@@ -68,7 +68,7 @@ resolve_ui_font() {
|
||||
printf '%s\n' "$_req"
|
||||
}
|
||||
|
||||
TNAME="$(xres_get theme.name "AnodeDefault")"
|
||||
TNAME="$(xres_get theme.name "Anodized")"
|
||||
DARK="$(xres_get theme.isDark "")"
|
||||
FONT_FACE="$(xres_get theme.fontFace "Fira Code")"
|
||||
MONO_FONT="$FONT_FACE"
|
||||
@@ -79,30 +79,30 @@ XFT_DPI="$(xres_get Xft.dpi "")"
|
||||
CUR_SZ="$(xres_get Xcursor.size "24")"
|
||||
ICON_THEME="$(xres_get theme.iconTheme "Adwaita")"
|
||||
|
||||
BG_MAIN="$(xres_get theme.bgMain "#0b0e14")"
|
||||
BG_BAR="$(xres_get theme.bgBar "#11161f")"
|
||||
BG_HEADER="$(xres_get theme.bgHeader "#141a24")"
|
||||
BG_FOOTER="$(xres_get theme.bgFooter "#0f141d")"
|
||||
BG_OVERLAY="$(xres_get theme.bgOverlay "#192231")"
|
||||
BG_ALT_EVEN="$(xres_get theme.bgAltEven "#131923")"
|
||||
BG_ALT_ODD="$(xres_get theme.bgAltOdd "#171f2b")"
|
||||
BG_INPUT="$(xres_get theme.bgInput "#1a2330")"
|
||||
BG_INPUT_FOC="$(xres_get theme.bgInputFocus "#202c3d")"
|
||||
BG_BUTTON="$(xres_get theme.bgButton "#1e2838")"
|
||||
BG_SEARCH="$(xres_get theme.bgSearch "#1b2433")"
|
||||
FG_MAIN="$(xres_get theme.fgMain "#e6e1cf")"
|
||||
FG_BRIGHT="$(xres_get theme.fgBright "#ffffff")"
|
||||
FG_MUTED="$(xres_get theme.fgMuted "#8693a6")"
|
||||
SEL_BG="$(xres_get theme.selBg "#2b5278")"
|
||||
SEL_FG="$(xres_get theme.selFg "#ffffff")"
|
||||
ACCENT="$(xres_get theme.accent "#59c2ff")"
|
||||
ACCENT_ALT="$(xres_get theme.accentAlt "#73d0ff")"
|
||||
HIGHLIGHT="$(xres_get theme.highlight "#ffd173")"
|
||||
BORDER="$(xres_get theme.border "#283444")"
|
||||
DIVIDER="$(xres_get theme.divider "#1e2736")"
|
||||
SUCCESS="$(xres_get theme.success "#7fd962")"
|
||||
WARNING="$(xres_get theme.warning "#ffb454")"
|
||||
DANGER="$(xres_get theme.danger "#f07178")"
|
||||
BG_MAIN="$(xres_get theme.bgMain "#08090b")"
|
||||
BG_BAR="$(xres_get theme.bgBar "#0e1014")"
|
||||
BG_HEADER="$(xres_get theme.bgHeader "#12151a")"
|
||||
BG_FOOTER="$(xres_get theme.bgFooter "#0b0d11")"
|
||||
BG_OVERLAY="$(xres_get theme.bgOverlay "#171b22")"
|
||||
BG_ALT_EVEN="$(xres_get theme.bgAltEven "#101318")"
|
||||
BG_ALT_ODD="$(xres_get theme.bgAltOdd "#14181f")"
|
||||
BG_INPUT="$(xres_get theme.bgInput "#161a21")"
|
||||
BG_INPUT_FOC="$(xres_get theme.bgInputFocus "#1e232c")"
|
||||
BG_BUTTON="$(xres_get theme.bgButton "#1c212a")"
|
||||
BG_SEARCH="$(xres_get theme.bgSearch "#191e27")"
|
||||
FG_MAIN="$(xres_get theme.fgMain "#e4e8ee")"
|
||||
FG_BRIGHT="$(xres_get theme.fgBright "#f5f7fa")"
|
||||
FG_MUTED="$(xres_get theme.fgMuted "#89929f")"
|
||||
SEL_BG="$(xres_get theme.selBg "#38414f")"
|
||||
SEL_FG="$(xres_get theme.selFg "#f5f7fa")"
|
||||
ACCENT="$(xres_get theme.accent "#cfd6e0")"
|
||||
ACCENT_ALT="$(xres_get theme.accentAlt "#e5eaf0")"
|
||||
HIGHLIGHT="$(xres_get theme.highlight "#e2bc72")"
|
||||
BORDER="$(xres_get theme.border "#2d3440")"
|
||||
DIVIDER="$(xres_get theme.divider "#20252f")"
|
||||
SUCCESS="$(xres_get theme.success "#79cf9c")"
|
||||
WARNING="$(xres_get theme.warning "#e2bc72")"
|
||||
DANGER="$(xres_get theme.danger "#e07a7a")"
|
||||
|
||||
THEME_ID="ANODE-$TNAME"
|
||||
|
||||
|
||||
@@ -166,8 +166,8 @@ if "$PKG_CFG" --exists xscrnsaver 2>/dev/null; then
|
||||
POWERD_DEFS="-DHAVE_XSCRNSAVER=1"
|
||||
fi
|
||||
|
||||
DWM_CFLAGS="$("$PKG_CFG" --cflags fontconfig freetype2 xft pango pangoxft harfbuzz x11 xinerama xrender)"
|
||||
DWM_LIBS="$("$PKG_CFG" --libs fontconfig freetype2 xft pango pangoxft harfbuzz x11 xinerama xrender)"
|
||||
DWM_CFLAGS="$("$PKG_CFG" --cflags fontconfig freetype2 xft pango pangoxft harfbuzz x11 xinerama xrandr xrender)"
|
||||
DWM_LIBS="$("$PKG_CFG" --libs fontconfig freetype2 xft pango pangoxft harfbuzz x11 xinerama xrandr xrender)"
|
||||
|
||||
DMENU_CFLAGS="$("$PKG_CFG" --cflags fontconfig freetype2 xft pango pangoxft harfbuzz x11 xfixes xi xinerama)"
|
||||
DMENU_LIBS="$("$PKG_CFG" --libs fontconfig freetype2 xft pango pangoxft harfbuzz x11 xfixes xi xinerama) -lm"
|
||||
|
||||
Reference in new issue
Block a user