shell(bin): add is-system-theme-light

This commit is contained in:
PowerUser64 2025-07-15 22:41:51 -07:00
parent 85281b225d
commit ce05002f35

View file

@ -0,0 +1,41 @@
#!/bin/bash
# Checks the system light/dark theme status
# Returns 0 (true) if the theme is light, 1 (false) if the theme is dark
set -e
declare -- method theme
# Figure out what environment we're in, so we can use the correct detection method
if [ -n "$SSH_TTY" ]; then
method=ssh
elif [ -n "$KDE_SESSION_UID" ]; then
method=kde
else
method=unknown
fi
set -u
config_dir="${XDG_CONFIG_HOME:-"$HOME"/.config}"
case "$method" in
(ssh) theme=dark;;
(kde)
if grep -Fq dark "$config_dir/kdeglobals"; then
theme=dark
else
theme=light
fi
;;
(unknown|*)
# assume dark theme
theme=dark
;;
esac
if [ "$theme" = light ]; then
exit 0
else
exit 1
fi