Add light/dark mode toggle using xsettingsd

This commit is contained in:
Alex Selimov 2025-01-15 22:44:59 -05:00
parent eb87e6387e
commit f75d294a5b
4 changed files with 120 additions and 101 deletions

17
bin/swap_mode.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash
# Script for changing between light and dark modes
mode=$(grep "light_mode = " ~/.wezterm.lua | cut -d "=" -f 2 | tr -d " ")
if [ "$mode" = "true" ]; then
echo "Swapping to dark mode"
sed -i -e "s/local light_mode =.*/local light_mode = false/" ~/.wezterm.lua
sed -i -e 's@Net/ThemeName.*@Net/ThemeName "Orchis-Grey-Dark"@' ~/.xsettingsd
sed -i -e "s/light.rasi/dark.rasi/" $HOME/.config/rofi/config.rasi
else
echo "Swapping to light mode"
sed -i -e "s/local light_mode =.*/local light_mode = true/" ~/.wezterm.lua
sed -i -e 's@Net/ThemeName.*@Net/ThemeName "Orchis-Grey-Light"@' ~/.xsettingsd
sed -i -e "s/dark.rasi/light.rasi/" $HOME/.config/rofi/config.rasi
fi
killall -HUP xsettingsd