toggle-theme.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. # Script to toggle between light / dark mode
  3. # Set this to where Waybar reads its config files
  4. WAYBAR_DIR="$HOME/.config/waybar"
  5. SWAYNC_DIR="$HOME/.config/swaync"
  6. KITTY_DIR="$HOME/.config/kitty"
  7. CURRENT_SCHEME=$(gsettings get org.gnome.desktop.interface color-scheme)
  8. if [ "$CURRENT_SCHEME" == "'prefer-dark'" ]; then
  9. gsettings set org.gnome.desktop.interface color-scheme 'prefer-light'
  10. # Copy the light theme to theme.css
  11. cp "$WAYBAR_DIR/light.css" "$WAYBAR_DIR/theme.css"
  12. cp "$SWAYNC_DIR/light.css" "$SWAYNC_DIR/theme.css"
  13. ln -sf "$KITTY_DIR/light_theme.conf" "$KITTY_DIR/theme.conf"
  14. notify-send "Light Mode" -a "System"
  15. else
  16. gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
  17. # Copy the dark theme to theme.css
  18. cp "$WAYBAR_DIR/dark.css" "$WAYBAR_DIR/theme.css"
  19. cp "$SWAYNC_DIR/dark.css" "$SWAYNC_DIR/theme.css"
  20. ln -sf "$KITTY_DIR/dark_theme.conf" "$KITTY_DIR/theme.conf"
  21. notify-send "Dark Mode" -a "System"
  22. fi
  23. # Sends signals to these processes to speed up the theme switch
  24. killall -SIGUSR2 waybar
  25. killall -SIGUSR1 nvim
  26. pkill -USR1 kitty
  27. swaync-client -rs