lupan-set-theme: toggle based on existence of ~/.lightmode, update dwm theme

This commit is contained in:
2025-10-07 09:01:26 +02:00
parent bce8fbc87c
commit 7c05d57053

View File

@@ -2,24 +2,27 @@
THEME="$1" THEME="$1"
XSET=$(readlink -e ~/.config/xsettingsd/xsettingsd.conf)
if [ "$THEME" = "toggle" ]; then if [ "$THEME" = "toggle" ]; then
if grep Materia-dark "$XSET" > /dev/null; then if [ -e ~/.lightmode ]; then
THEME=light
else
THEME=dark THEME=dark
else
THEME=light
fi fi
fi fi
if [ "$THEME" = dark ]; then if [ "$THEME" = dark ]; then
GTK_THEME=Materia-dark GTK_THEME=Materia-dark
rm -f ~/.lightmode
elif [ "$THEME" = light ]; then elif [ "$THEME" = light ]; then
GTK_THEME=Materia-light GTK_THEME=Materia-light
touch ~/.lightmode
else else
echo "error: unknown theme: should be either dark, light or toggle" >&2 echo "error: unknown theme: should be either dark, light or toggle" >&2
exit 1 exit 1
fi fi
killall -USR1 dwm
XRES=$(readlink -e ~/.Xresources) XRES=$(readlink -e ~/.Xresources)
if [ -n "$XRES" ]; then if [ -n "$XRES" ]; then
if [ "$THEME" = dark ]; then if [ "$THEME" = dark ]; then
@@ -41,6 +44,7 @@ if [ -f "$ATOML" ]; then
sed -i "s#^import =.*#import = [\"~/.config/alacritty/$THEME.toml\"]#" "$ATOML" sed -i "s#^import =.*#import = [\"~/.config/alacritty/$THEME.toml\"]#" "$ATOML"
fi fi
XSET=$(readlink -e ~/.config/xsettingsd/xsettingsd.conf)
if [ "$THEME" = dark ]; then if [ "$THEME" = dark ]; then
kitten themes --reload-in=all Afterglow kitten themes --reload-in=all Afterglow
elif [ "$THEME" = light ]; then elif [ "$THEME" = light ]; then