Skip to content

Instantly share code, notes, and snippets.

@MisterPixels
Created February 8, 2018 13:27
Show Gist options
  • Save MisterPixels/04cb30f112dbd257cbc25f2f757cb797 to your computer and use it in GitHub Desktop.
Save MisterPixels/04cb30f112dbd257cbc25f2f757cb797 to your computer and use it in GitHub Desktop.
#!/bin/bash
folder=$1 #store the first given arguement to folder
seconds=$2 #store the second given arguement to seconds
if [ $1 == "kill" ] # if the first arguement is "kill" then kill the script wallpaperslideshow.sh
then
killall wallpaperslideshow.sh # kills the script wallpaperslideshow.sh
else # else run the following
while [ true ] # creates a infinite loop
do
maxnumber=$(ls $folder | wc -l) # stores the number of the maximum amount of files in the folder
filename=$(ls $folder | sed $((1 + RANDOM % $maxnumber))'q;d') # stores the name of the file at random from 1 to maximum number of files in folder
if [ `echo $filename | grep .png` ] || [ `echo $filename | grep .jpg` ] || [ `echo $filename | grep .jpeg` ] || [ `echo $filename | grep .gif` ] # if the file chosen is a jpg, jpeg, png or gif
then
pcmanfm --set-wallpaper="$folder/$filename" # set the wallpaper to the random file chosen
sleep $seconds # sleep for amount of seconds given by the user
fi
done
fi
@bottaluscio
Copy link

Hi MisterPixels,
I want to thank you for this awesome script you made, it really inspired me and I'd like to share with you my version, hope you like it.
https://bitbucket.org/roberto_benedetti/lxde-slideshow-wallpaper/src/master/

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