Skip to content

Instantly share code, notes, and snippets.

@D3Ext
Created January 5, 2023 23:09
Show Gist options
  • Save D3Ext/173dc68caa45e686303affc7bde2659b to your computer and use it in GitHub Desktop.
Save D3Ext/173dc68caa45e686303affc7bde2659b to your computer and use it in GitHub Desktop.
Automatic dark/light theme changer
#!/bin/bash
# This script is designed to run on background to change between light and dark theme
night_hour="22:00"
day_hour="9:00"
dark_wallpaper="/usr/share/backgrounds/home127-dark.jpg"
light_wallpaper="/usr/share/backgrounds/home127-light.jpg"
while true; do # Enter main loop
current_hour=$(date +%H:%M) # Get hour format
if [[ "${current_hour}" > "${night_hour}" ]] && [[ "${current_hour}" < "${day_hour}" ]]; then # Check if current date is between two defined hours
# Night stuff is done here
feh --bg-fill "${dark_wallpaper}"
else
# Day stuff is done here
feh --bg-fill "${light_wallpaper}"
fi
sleep 10 # Waits 10 seconds until next check
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment