shell(bin): add is-system-theme-light
This commit is contained in:
parent
85281b225d
commit
ce05002f35
1 changed files with 41 additions and 0 deletions
41
.config/shell/bin/is-system-theme-light
Executable file
41
.config/shell/bin/is-system-theme-light
Executable 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
|
Loading…
Add table
Add a link
Reference in a new issue