Skip to content

Instantly share code, notes, and snippets.

@anthony-y
Created September 9, 2021 00:05
Show Gist options
  • Save anthony-y/a7213e2f1db91aeee872661b296b13e1 to your computer and use it in GitHub Desktop.
Save anthony-y/a7213e2f1db91aeee872661b296b13e1 to your computer and use it in GitHub Desktop.
Script I wrote to change my system theme automatically throughout the day.
#!/bin/python
import datetime as dt
import time
import os
SUNSET = 20 # switch to dark mode at 8PM
SUNRISE = 6 # day starts at 6AM
DAY_WP = "/home/ant/Pictures/wallpapers/day"
NIGHT_WP = "/home/ant/Pictures/wallpapers/night"
# DAY_THEME = "Pop"
DAY_THEME = "Materia-light-compact"
NIGHT_THEME = "Pop-dark"
DAY_KITTY = "/home/ant/.config/kitty/Github.conf"
NIGHT_KITTY = "/home/ant/.config/kitty/Jellybeans.conf"
WALLPAPER_COMMAND = "gsettings set org.gnome.desktop.background picture-uri {}"
THEME_COMMAND = "gsettings set org.gnome.desktop.interface gtk-theme {}"
KITTY_COMMAND = "rm /home/ant/.config/kitty/theme.conf; ln -s {} /home/ant/.config/kitty/theme.conf; kitty @ set-colors -a {}"
if __name__ == '__main__':
while (True):
wallpaper = ""
theme = ""
kitty = ""
now = dt.datetime.now()
if now.hour >= SUNSET or now.hour < SUNRISE:
wallpaper = NIGHT_WP
theme = NIGHT_THEME
kitty = NIGHT_KITTY
else:
wallpaper = DAY_WP
theme = DAY_THEME
kitty = DAY_KITTY
os.system(WALLPAPER_COMMAND.format(wallpaper))
os.system(THEME_COMMAND.format(theme))
os.system(KITTY_COMMAND.format(kitty, kitty))
time.sleep(1 * 60) # check every minute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment