toggle-theme.sh 770 B

123456789101112131415161718192021
  1. #!/usr/bin/env bash
  2. # Set this to where Waybar reads its config files
  3. WAYBAR_DIR="$HOME/.config/waybar"
  4. CURRENT_SCHEME=$(gsettings get org.gnome.desktop.interface color-scheme)
  5. if [ "$CURRENT_SCHEME" == "'prefer-dark'" ]; then
  6. gsettings set org.gnome.desktop.interface color-scheme 'prefer-light'
  7. # Copy the light theme to theme.css
  8. cp "$WAYBAR_DIR/light.css" "$WAYBAR_DIR/theme.css"
  9. notify-send "Light Mode" -a "System"
  10. else
  11. gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
  12. # Copy the dark theme to theme.css
  13. cp "$WAYBAR_DIR/dark.css" "$WAYBAR_DIR/theme.css"
  14. notify-send "Dark Mode" -a "System"
  15. fi
  16. # Send SIGUSR2 to Waybar so it dynamically reloads style.css (which now imports theme.css)
  17. killall -SIGUSR2 waybar