Created
September 18, 2021 20:37
-
-
Save rifazn/50b4fa6b297137756a0f97b655026967 to your computer and use it in GitHub Desktop.
Hook for gammastep that changes between light and dark variants of theme
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/sh | |
# Rifaz Nahiyan | |
# https://github.com/rifazn | |
# Hook for gammastep that changes between light and dark variants of theme | |
# Place this in $XDG_CONFIG_DIR/gammastep/hooks/ | |
# TODO: if prefers-dark-theme is set to true, don't do anything | |
set_theme () { | |
gsettings set org.gnome.desktop.interface gtk-theme "$1" | |
} | |
# Default light variant of theme is set in ~/.config/gtk-3.0/settings.ini | |
# Set light and dark variants according to that | |
current_theme="$(gsettings get org.gnome.desktop.interface gtk-theme)" | |
# this value is contained in ''. So filter that | |
current_theme="${current_theme:1:-1}" | |
# current_theme might be the dark variant, so trim that | |
light_variant="${current_theme%-Dark}" | |
dark_variant="${light_variant}-Dark" | |
case "$1" in | |
"period-changed") | |
# Test some echos | |
notify-send "gammastep period change at $(date "+%H:%M")" "$(echo "$@")" | |
if [[ "$3" = "night" ]]; then | |
set_theme "$dark_variant" | |
elif [[ "$3" = "daytime" ]]; then | |
set_theme "$light_variant" | |
fi | |
esac | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment