pub / theme-switchers

Switching Themes for various GNU+Linux software
git clone src.jayvii.de/pub/theme-switchers.git
Home | Log | Files | Exports | Refs | README | RSS

gnome-switch-theme.sh (921B)


      1 #!/usr/bin/env bash
      2 
      3 # exit on error
      4 set -eo pipefail
      5 
      6 # check whether input was given
      7 if [ -z $1 ]; then
      8   # get current GTK theme
      9   target=$(gsettings get org.gnome.desktop.interface color-scheme)
     10 else
     11   target="$1"
     12 fi
     13 
     14 export XDG_RUNTIME_DIR="/run/user/$(id -u)"
     15 export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"
     16 
     17 # If we want a dark theme, but the current theme is not, switch theme to dark
     18 if [[ "$target" == "'prefer-light'" ]] || [[ "$target" == "dark" ]]; then
     19   gsettings set org.gnome.desktop.interface color-scheme "prefer-dark"
     20   echo "[✓] Switched gnome to dark!"
     21 
     22 # If we want a light theme, but the current theme is not, switch theme to light
     23 elif [[ "$target" == "'prefer-dark'" ]] || [[ "$target" == "light" ]]; then
     24   gsettings set org.gnome.desktop.interface color-scheme "prefer-light"
     25   echo "[✓] Switched gnome to light!"
     26 
     27 else
     28   echo "[-] Did not switch theme: $sys_theme"
     29 
     30 fi