Last active
March 14, 2022 17:28
-
-
Save icy-arctic-fox/7a7fa44a47d9dce3ba0159f4b7f67209 to your computer and use it in GitHub Desktop.
Linux Mint Cinnamon Dark Mode
This file contains 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
# Every day at 07:00 disable dark mode. | |
0 7 * * * /bin/sh /home/michael/.local/bin/dark-mode.sh false | |
# Every day at 21:00 enable dark mode. | |
0 21 * * * /bin/sh /home/michael/.local/bin/dark-mode.sh true |
This file contains 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 | |
# Changes the theme to use a dark variant and attempt to update applications. | |
# This script doesn't completely work - some programs may need to be restarted to see the change. | |
# Usage: dark-mode.sh [true|false] | |
# Name of the theme to use. | |
# The dark variant should be "NAME-Dark" | |
theme="Arc" | |
# Check input, default to enable dark mode. | |
action="$1" | |
test -z "$action" && action=true | |
if [ "$action" = 'true' ]; then | |
# Switch to dark theme. | |
SEARCH=gtk-application-prefer-dark-theme=false | |
REPLACE=gtk-application-prefer-dark-theme=true | |
theme="$theme-Dark" | |
else | |
# Switch to light theme. | |
SEARCH=gtk-application-prefer-dark-theme=true | |
REPLACE=gtk-application-prefer-dark-theme=false | |
fi | |
# Let applications know to use dark theme. | |
/bin/sed -i 's/'$SEARCH'/'$REPLACE'/g' /home/michael/.config/gtk-3.0/settings.ini | |
# Set Gnome, Cinnamon, and GTK settings. | |
/usr/bin/gsettings set org.cinnamon.desktop.interface gtk-theme "$theme" | |
/usr/bin/gsettings set org.cinnamon.desktop.interface gtk-color-scheme "" | |
/usr/bin/gsettings set org.cinnamon.desktop.wm.preferences theme "$theme" | |
/usr/bin/gsettings set org.cinnamon.theme name "$theme" | |
/usr/bin/gsettings set org.gnome.desktop.interface gtk-theme "$theme" | |
/usr/bin/gsettings set org.gnome.desktop.interface gtk-color-scheme "" | |
/usr/bin/gsettings set org.gnome.desktop.wm.preferences theme "$theme" | |
/usr/bin/gconftool --type=string --set /desktop/cinnamon/windows/theme "$theme" | |
# Refresh GTK applications. | |
# https://crunchbang.org/forums/viewtopic.php?pid=428525#p428525 | |
python - <<END | |
import gtk | |
events=gtk.gdk.Event(gtk.gdk.CLIENT_EVENT) | |
data=gtk.gdk.atom_intern("_GTK_READ_RCFILES", False) | |
events.data_format=8 | |
events.send_event=True | |
events.message_type=data | |
events.send_clientmessage_toall() | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment