Skip to content
February 4, 2012 / mb

Make your own picture-changing wallpaper in Gnome3

I hoped Gnome3 would have had an integrated function to create custom wallpapers that change throughout the day by picking a folder with your images and choose some refresh interval, but still you have to rely on external scripts or programs.

I’ve been using WallCh for quite some time under Unity, and it suited me well. It was a bit too much for what I wanted to actually do, grabbing pictures in a folder and set them as wallpaper every 3 minutes that is.

Another thing that “annoyed” me is that while in Unity minimized windows are quite the same thing as background processes — in that they just stay on the Unity dash and as long as you don’t hit Alt+Tab they never show up — in Gnome3 I very often go through the list of all open applications, and WallCh by default is always there. I’m not a fan of Alt+Tab in Gnome3: I find it faster to hit Super with my left hand and click on a window I instantly recognize with my right hand than to cycle through small pictures with titles. I don’t know whether WallCh has an option to run in the background, but if it does I didn’t instantly find it and I opted for a little DIY :P

That being said I thought that surely a simple command must exist to just change the wallpaper, and it does! It’s gsettings, with its org.gnome.desktop.background keys. So, to set your ~/Images/1080p/wall_0.png as background you just call

gsettings set org.gnome.desktop.background picture-uri file://$HOME/Images/1080p/wall_0.png
gsettings set org.gnome.desktop.background picture-options zoom

you can just add these two system calls in some simple script in whatever language you like and there you have your custom wallpaper changer!

I came up with a simple python script which is actually a stripped-down version of this nice little script by Romano Giannetti. I simply removed all verbosity and moved the pictures folder definition to a properties file that is checked at every interval, so I never have to change the script itself. If anyone is interested, I’ll post it (it’s less than 50 LOC in the end).

Then, I added the script as a startup application with gnome-session-properties so I finally have my lightweight background wallpaper changer :)

Edit: as Romano himself asked for it, here’s my version of the script: http://pastebin.com/embed_iframe.php?i=UGYNi0K5

Well, if truth be told my version of the script has no error checks whatsoever, but since somebody may try to use this I thought that some information on what’s going on may be helpful. You can list several folders in the configuration file; if you change the configuration file while the script is running the list gets parsed again and reset.

About these ads

6 Comments

Leave a Comment
  1. Romano / Feb 4 2012 13:24

    Happy to help. And yes, publish your version too, so I can learn how you do it!

    • mb / Feb 5 2012 14:57

      There you go! I hope you’re ok with the “licensing”.. :)
      If not I’ll change it straight away, of course!

      • Romano / Feb 5 2012 16:43

        I’m ok with it. By the way, how do you manage an added image file to one of the directory, without changing the conf file? Will it be ever picked up?

      • mb / Feb 5 2012 18:20

        ha! I didn’t think about that! Thanks :)
        Now it deals with new files being added, and it updates the current round accordingly (where a round is a single permutation of all files in all configured folders): this means that if we have images A, B and C and a new image D is added after B and A have been set as wallpaper, images C and D will be set before A or B may be showed again. Every round is shuffled so as to avoid the same sequence running all over again. So much for the “stripped down” version :D

  2. EJ / Apr 30 2012 22:36

    Hey there,

    Love the script, it’s exactly what I was looking for. It bothered me that the way I run it from gnome-session-properties launches multiple processes after a suspend so I added a pid file check and signal traps to clean up the pid:

    http://pastebin.com/iaC6MRZf

    The only thing I want to add now is a way to “fade out/in” the backgrounds – any idea where I might start looking for something like that? I don’t even know where to begin.

    Cheers

    • mb / Apr 30 2012 23:19

      as a matter of fact I never checked the PIDs so your changes are very welcome!

      For background transitions I stumbled onto this answer to a question on askubuntu, and it seems that you can define transitions using XML files as backgrounds, give it a look!

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: