toggle-theme.sh 1.0 KB

123456789101112131415161718192021222324252627282930
  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. else
  15. gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
  16. # Copy the dark theme to theme.css
  17. cp "$WAYBAR_DIR/dark.css" "$WAYBAR_DIR/theme.css"
  18. cp "$SWAYNC_DIR/dark.css" "$SWAYNC_DIR/theme.css"
  19. ln -sf "$KITTY_DIR/dark_theme.conf" "$KITTY_DIR/theme.conf"
  20. fi
  21. # Sends signals to these processes to speed up the theme switch
  22. killall -SIGUSR2 waybar
  23. killall -SIGUSR1 nvim
  24. pkill -USR1 kitty
  25. swaync-client -rs