LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-04-2017, 03:08 PM   #1
shwaybotx
LQ Newbie
 
Registered: Mar 2017
Location: Amarillo, T Amateur photographer, published author. Interests: astronomy, political science & freedom of press. Been: 37 countries. Lived: 3 continents.X
Distribution: linux mint mate kfce 18.1
Posts: 7

Rep: Reputation: Disabled
My Tutorial: Rotating Gnome Wallpaper.


Step by step how you can get Gnome to rotate your desktop wallpaper
I’ve recently been exploring the world of Gnome 3 inside my Antergos Linux computer. Since Antergos is slightly different than Arch I do not know if this will work with an Arch system or not, but it sure works on my Antergos system. A copy of this tutorial can be found here, and also on my blog at RationalThinking101.com, just in case (inevitable) I have to reinstall and lose this configuration then I can find it here, and you can use it too!

My mission in this tutorial: Show step by step how you can get Gnome to rotate your desktop wallpaper regularly and automatically. Forgive me if this tutorial is too verbose.

Please note although I am running Antergos, my system may be different than your system. I may have encountered problems that you will not encounter or visa versa. In my initial Antergos installation, I chose Xfce as my desktop environment. I added Gnome to my setup later on. That may make my system slightly different from yours. This tutorial works on my computer. It will probably work on yours if you use Antergos. It might even work for you if you run Manjaro or Arch. I do not know. You can change the instructions below at your own risk. This is what I did and if you do exactly like this it’s going to work on Antergos.

Step 1: Have a Wallpaper folder with pictures in it
On my computer I have created a Wallpaper folder inside Pictures. I regularly search Google images for “nature” and specify to show me images larger than 2 mb. I add images to this folder all the time. However you collect your wallpaper pictures is really up to you. This tutorial assumes you already have a bunch of your own wallpaper pictures and you have them stored in ./Pictures/Wallpaper

Step 2: Create a script
a. open a terminal. Create a folder in your home folder.

mkdir bin
Close your terminal and go back to your desktop.

b. Open mousepad. You can find it by listing all of your Gnome programs. If you do not have mousepad (maybe your Gnome didn’t come with that text editor), then go and install it.

Once mousepad is open, you’ll have a blank screen. Copy the following code and paste it into your blank mousepad window:

#!/usr/bin/sh
/home/[user]/Pictures/Wallpaper/ | shuf -n 1)'"'
PID=$(pgrep gnome-session)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-) gsettings=dconf
gsettings set org.gnome.desktop.background picture-uri '"file://'/home/[user]/Pictures/Wallpaper/$(ls /home/[user]/Pictures/Wallpaper/|shuf -n 1)'"'
Do not remove the first line: #!/usr/bin/sh – that has to be there exactly as written.

Once you paste this into mousepad, you have to edit it. There are exactly 3 times the following text appears in this file: [user]. You have to replace [user] with your Linux username. Brackets and all should go. So if your username is “samantha” you will replace [user] with samantha. Make sure you get all three of them.

c. Save the script
We will now save this file. Save the file with this name: ~/bin/rotate_bg.sh

Close mousepad. Your script is created as a text file called rotate_bg.sh and it is stored in a folder “bin” inside your home directory.

d. Make the script executable
Now we must make the script executable in order for it to be useful. To do that, open a terminal and enter this command:

chmod u+x ~/bin/rotate_bg.sh
Still inside the terminal, test the script to see if it works. If it doesn’t you did something wrong from above and you need to go back and figure out where your mistake is. To see if the script successfully changes your Gnome desktop wallpaper, simply run it. Paste this into your terminal then press enter. Did your gnome wallpaper change? It does on mine, it should on yours.

./bin/rotate_bg.sh
Step 3: Make sure you have crond installed on your system.
In my case, crontab was not preinstalled on my Antergos system. I had to install it, and reboot, start it, reboot. It seemed like everything I did with it I had to reboot to get it to work. I don’t know if that’s normal or necessary, but it now works over here, even if I reboot, without further fussing with it.

crond is the daemon for cron, and crontab is a file for cron to follow when it’s running. I got it from the regular repositories.

Open the Antergos Add/Remove Software tool and search for “crond” – I wound up with a package called vixie-cron. I installed that. If you cannot find that specific package with your Add/Remove software tool, look in AUR. See if searching for crontab works. As stated, I installed vixie-cron.

Then you could reboot. Or you can carry on. If you reboot, don’t loose this tutorial. Bookmark it or something.

Step 4: start cron
Open a terminal, log on as root, and start cron. Don’t use sudo for this. Login with su.

su
cron start
exit
Step 5: Make a schedule to run your script
To make your desktop wallpaper script run regularly you have to edit crontab for your username. In the below example, replace [user] with your Linux username. Remove the brackets while you’re at it.

sudo crontab -u [user] -e
Example: Again, if your username is “samantha” it will look like this.

sudo crontab -u samantha -e
This will open your default text file editing program. Paste the following into it. Make sure you replace [user] with your username.

# (m) (h) (dom) (dow) (command)
#
* * * * * /home/[user]/bin/rotate_bg.sh
You need to understand what’s going on here because this may not be what you want. This tells cron to run your script every minute of every day. Your desktop wallpaper will change a lot, frequently. This is good for testing purposes, but later you might want to change it to every 10 minutes or once an hour. I’ll show you below how to do that. First thing first.

Save and exit. For me it would be Ctrl-X – accept the default file name, do not change the name – and then save and back to your command prompt.

Bookmark this tutorial, reboot your computer and log back into Gnome. Sit back and enjoy the show.

Step 6: Change Wallpaper from every minute to once every 10 minutes or once an hour.
If all goes well and it’s working correctly, you may want to go back and edit your crontab using the sudo crontab -u [user] -e command. If you want to run it only once each hour, you have to set the first item on the line (*) to something else other than *, for example:
20 * * * * /home/[user]/bin/rotate_bg.sh
The above example will change your wallpaper 20 minutes after every hour of every day.

Suppose you want to run it once every 10 minutes:
*/10 * * * * /path/to/script (change /path/to/script to the correct directory where rotate_bg.sh is located).

That’s it. Good luck.
 
Old 04-04-2017, 03:15 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,452
Blog Entries: 13

Rep: Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773
Great ideas you've shown here!

There also is a wallpaper swapper utility or option which I long ago added or configured and it uses a source directory, you either specify or can choose the default. You can set it for random or in series, and you can have different wallpapers for all workspaces. This is native to gnome, you just have to be within the gconfig utility to see it and use it.
 
1 members found this post helpful.
Old 04-10-2017, 08:07 PM   #3
shwaybotx
LQ Newbie
 
Registered: Mar 2017
Location: Amarillo, T Amateur photographer, published author. Interests: astronomy, political science & freedom of press. Been: 37 countries. Lived: 3 continents.X
Distribution: linux mint mate kfce 18.1
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rtmistler View Post
Great ideas you've shown here!

There also is a wallpaper swapper utility or option which I long ago added or configured and it uses a source directory, you either specify or can choose the default. You can set it for random or in series, and you can have different wallpapers for all workspaces. This is native to gnome, you just have to be within the gconfig utility to see it and use it.
Thanks. I actually found a problem with my cron idea and instead set up an Antergos systemd timer that runs that wallpaper rotate script, and now it "sticks" after rebooting. I'll check out your wallpaper swapper too, but things are working great here. Maybe I should leave well enough alone!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Rotating you Gnome 3 Background images LXer Syndicated Linux News 0 08-08-2011 07:30 AM
LXer: Set a Rotating Picture of the Earth as Your Ubuntu Wallpaper LXer Syndicated Linux News 0 06-06-2010 06:02 PM
rotating wallpaper in XFCE Furlinastis Slackware 6 06-02-2005 02:40 PM
Gnome wallpaper mbeattie74 Linux - Software 5 02-27-2005 07:37 PM
Rotating Backgrounds in Gnome -=Sabin=- Linux - General 1 07-19-2003 09:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration