Skip to content

Instantly share code, notes, and snippets.

@pm98zz-c
Last active April 20, 2022 15:58
Show Gist options
  • Save pm98zz-c/1a1a6e744ede8b4fd4fe to your computer and use it in GitHub Desktop.
Save pm98zz-c/1a1a6e744ede8b4fd4fe to your computer and use it in GitHub Desktop.
Indoor-Outdoor gnome-theme switching
#!/bin/sh
### DEPRECATED
### MOVED TO https://github.com/pm98zz-c/in-outdoor
####################################################
### Gnome 3 general.
TERMINAL_DARK="false"
OUT_THEME="'Adwaita'" # Legacy GTK
IN_THEME="'Adwaita-dark'"
OUT_BRIGHTNESS="100%"
IN_BRIGHTNESS="85%"
CURRENT_THEME="$(dconf read /org/gnome/desktop/interface/gtk-theme)"
SWITCH_THEME="$OUT_THEME"
SWITCH_BRIGHTNESS="$OUT_BRIGHTNESS"
SHELL_THEME="prefer-light" # Gnome 42
if [ "$CURRENT_THEME" = "$OUT_THEME" ]; then
SWITCH_THEME="$IN_THEME"
TERMINAL_DARK="true"
SWITCH_BRIGHTNESS="$IN_BRIGHTNESS"
SHELL_THEME="prefer-dark"
fi
dconf write /org/gnome/desktop/interface/gtk-theme "$SWITCH_THEME"
dconf write /org/gnome/desktop/wm/preferences/theme "$SWITCH_THEME"
dconf write /org/gnome/desktop/interface/icon-theme "$SWITCH_THEME"
gsettings set org.gnome.desktop.interface color-scheme "$SHELL_THEME"
### Visual Studio Code.
VS_CODE_SETTINGS="$HOME/.config/Code/User/settings.json"
VS_CODE_OUT_THEME="Default Light+"
VS_CODE_IN_THEME="Default Dark+"
REPLACE="s/$VS_CODE_IN_THEME/$VS_CODE_OUT_THEME/g"
if [ "$TERMINAL_DARK" = "true" ]; then
REPLACE="s/$VS_CODE_OUT_THEME/$VS_CODE_IN_THEME/g"
fi
sed -e "$REPLACE" "$VS_CODE_SETTINGS" > /tmp/vscsettings.tmp && mv /tmp/vscsettings.tmp "$VS_CODE_SETTINGS"
### Screen brightness (see https://github.com/Hummer12007/brightnessctl)
brightnessctl set "$SWITCH_BRIGHTNESS" > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment