Last active
January 15, 2022 05:13
-
-
Save FlyingJester/9142028 to your computer and use it in GitHub Desktop.
A script that uses `feh` to randomly set the desktop background, changing it every 5 minutes, and not repeating any image twice.
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
# Calls Feh, puts a randomized image on the background, and changes | |
# the image every 5 minutes. | |
import os | |
import glob | |
import subprocess | |
import time | |
import random | |
images = glob.glob('images/*') | |
for image in images: | |
print image | |
first = images[0] | |
delay = 5 #5 minutes. | |
while True: | |
#randomize the order. | |
#Ensure that we don't have the same first element as the last element. | |
while first== images[0]: | |
random.shuffle(images) | |
for image in images: | |
feh = subprocess.Popen(['feh', '--bg-fill', image]) | |
time.sleep(delay * 60) | |
#record the last image. | |
first = image | |
#be a nice guy. | |
feh.terminate() | |
random.shuffle(images) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks man!