Skip to content

Instantly share code, notes, and snippets.

@FlyingJester
Last active January 15, 2022 05:13
Show Gist options
  • Save FlyingJester/9142028 to your computer and use it in GitHub Desktop.
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.
# 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)
@jadia
Copy link

jadia commented Jun 25, 2021

Thanks man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment