Automatic wallpaper changing script for lxde


Yesterday, I was looking for a script to automaticly change my lxde wallpaper, and after a long searching I found a nice way to do that. I worte these 2 scripts.

The first script picks a random wallpaper from your wallpapers directory and sets it as wallpaper.

The second script runs the first script every specified time.

Put these 2 scripts in /usr/bin/

Save this one as /usr/bin/rotator


picturesPath=/usr/share/backgrounds #Your wallpapers folder

#IFS="$(printf '\n\t')"
#allFiles=( $(find "$picturesPath" -maxdepth 1 -type f) )

for f in $picturesPath/*; do
    if [ -f "$f" ]


if [ ${allFilesCount} -eq 0 ]
    exit 1

selectedFileIdx=$[ ( $RANDOM % ${allFilesCount} ) ]

if  [ -f "$selectedFile"  ]
    echo "$selectedFile"
     sleep 1s #increase if problems
    pcmanfm --set-wallpaper="$selectedFile" #you can change this command with your desktop manager's one

after saving, run “sudo chmod +x /usr/bin/rotator”

And save this one as /usr/bin/autowall

while [ 1 -eq 1 ]; do

   sleep 15m #Change wallpaper interval, This is 15 minutes

then run “sudo chmod +x /usr/bin/autowall”

After that, add this line to your ~/.config/lxsession/LXDE/autostart to automaticly run the script at startup.




6 thoughts on “Automatic wallpaper changing script for lxde

  1. There is a simpler way:
    while true; do
    pcmanfm –set-wallpaper=”$(find $DIR -type f | shuf -n1)”
    sleep 3h
    it works for all files and folders in folder $DIR recursively

  2. That was Absolutely one on the best first time runners. It was totally kick ass once I directed the folder the my personal wallpaper folder. Absolutely works, I struggled with XLM files and other scripts, I do not know how how the write or interpret but yours was the best kick ass. I read the code and got an understanding of what it is doing. I apologize if other have issues. I using Linux mint 16 lxde as one of the desktops. My GF uses KDE.. I wanted a Wallpaper Changer too but I had to go to this and this makes it so my TV does not go into saver mode during a movie. Thank a bunch for you contribution. I hope I can help someone someday like you did.

Leave a Reply :)

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s