Last active
April 21, 2021 22:58
-
-
Save mutcianm/a3c710c0c3f86b41c10af9bcc88d0b7e to your computer and use it in GitHub Desktop.
Simple bash script to globally toggle dark/light look and feel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $1 == "dark" ]]; then | |
UI_THEME_GTK="Mojave-dark" | |
UI_THEME_QT="KvMojave" | |
UI_ICONS="Faenza-Ambiance" | |
VIM_BG="dark" | |
elif [[ $1 == "light" ]]; then | |
UI_THEME_GTK="Mojave-light" | |
UI_THEME_QT="KvMojaveLight" | |
UI_ICONS="Faenza-Radiance" | |
VIM_BG="light" | |
elif [[ $1 == "toggle" ]]; then | |
CURRENT=$(xfconf-query -c xsettings -p /Net/ThemeName) | |
[[ "$CURRENT" == *"dark"* ]] && exec $0 light || exec $0 dark | |
else | |
exit 1 | |
fi | |
mydir="${0%/*}" | |
# set GTK theme xia xsettings | |
xfconf-query -c xsettings -p /Net/ThemeName -s "$UI_THEME_GTK" | |
xfconf-query -c xsettings -p /Net/IconThemeName -s "$UI_ICONS" | |
# set or create and set persistent property for vim to read on startup | |
xfconf-query -c xsettings -p /Gtk/laf -s "$1" || xfconf-query -c xsettings -p /Gtk/laf -n -t string -s $1 | |
# set matching qt theme(doesn't apply to already running applications) | |
kvantummanager --set "$UI_THEME_QT" | |
# change 'background' option of all running nvim instances via RPC | |
find /tmp -path '/tmp/nvim*' -type s -exec $mydir/nvim-send {} "set background=$VIM_BG" \; | |
# change IntelliJ LaF via 'External LAF switch' plugin | |
echo "$1" | nc localhost 16666 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment