Thursday, December 29, 2011

Installation Notes and Rants for Ubuntu 11.10

A few weeks ago I updated Hal to Ubuntu 11.10 (Oneiric Ocelot). This was relatively easy because Hal was already at 11.04, allowing me to do a distribution update from the update manager. Our other Linux box, harlie, was running Ubuntu 10.10, so that option wasn't available unless I updated first to 11.04 and then to 11.10. Instead, I downloaded 11.10 to a CD, and did an install more or less for scratch.

Now, mind you, the Ocelot has what are supposedly a lot of nifty features, including the not-quite-Mac-like-enough-to-be-sued (you might want to ask Google about that) Unity desktop interface. And, if you don't like Unity, you can get Gnome 3! I didn't really want any of that. What I wanted was a machine that had all the modern software but looked and acted exactly like the old Ubuntu. I didn't quite get that, but I came pretty close.

BUT: This release of Ubuntu sets computing back at least 10 years. In the effort to make everything super friendly, they have dumbed down the user interface so much that you MUST use the command line to make even the simplest changes: For example, up through 11.04 you could easily change theme colors through a GUI widget. This is an appropriate use of the GUI, you can see what the current colors are, select the colors you want, and if they aren't right you can fix them right then and there. But now, guess what? THE ONLY WAY TO CHANGE THEME COLORS IS TO EDIT A FRAKIN' TEXT FILE. AS THE SUPERUSER! (I only shout because I'm mad.) This is (pick one):

  • Dumb
  • Dumber
  • So stupidly idiotic that one expects that there must be a malevolent being doing this, someone who wants everyone to throw up their hands in exasperation and switch to OS X. Or worse, Windows 8.

And this kind of idiocy exists all over the place: Things that were easy to do before are now hidden. Usually you have to edit a text file that hasn't appreciably changed since 1999. OK, I can do that, but until last month I didn't have to. Hence my frustration.

The worst of it is, this isn't just Ubuntu, a lot of the changes are driven by Gnome 3. It's enough to drive one back to the ugliness that is FVWM, where at least you know you have to edit menus going in.

But not just yet. Click below to see how I overcame the obstacles, at least so far.

Saturday, December 03, 2011

Random Wallpaper Switcher for GNOME 3

20 October 2012: There's a revised version of this script. See what the changes are, then download the new version.

21 July 2013: And yet another revision, following my switch from Ubuntu to LMDE: a MATE version of this software.

Some things bore me — KU losing in March every year, the Yankees winning more than one pennant a decade, Republican Presidential Debates, etc..

One of my major points of boredom is a static background on my computer screen. Having the same picture up constantly just irks.

Apple solved this long ago, with Mac OS X you can pick a directory and have the pictures selected randomly from that directory. Linux has been a little slow to pick this up. A random wallpaper selector has never shipped with any window manager I'm aware of, leaving the field to third-parties and home-grown hacking.

Way back in the day I wrote setbg, a clunky Perl script which randomly changed the X11 background. That worked for window mangers such as FVWM, but it failed for GNOME, which has its own wallpaper protocol.

For GNOME 2 I used Scott Balneaves's Gnome background switcher, aka background.py, a Python script which let you specify a directory and a switching time. Every X seconds you got a new picture for wallpaper.

GNOME 3 does wallpaper a different way (Surprise!). Fortunately I stumbled on a one-liner which changes the background to a random picture. If you want to do it that way, you just enter

gsettings set org.gnome.desktop.background picture-uri file://$(find DIR -type f | shuf -n1`)

where DIR is the path to your picture directory.

OK, I can work with that. I decided to write a script, based on the one-liner, which combined the best features of setbg and background.py. What I want is a script that:

  1. Displays a random picture as wallpaper (see the gsettings one-liner, above).
  2. Changes pictures at random times. Say someplace between every 10 minutes and every 20 minutes, but not always every 10 minutes and not always every 20 minutes. setbg did this, but background.py did not. If I knew more Python I would have fixed that, but I never had time.
  3. Can be loaded as a Startup Application (now conveniently located in Applications/Other on your Ubuntu menu).
  4. Works on any Linux computer running GNOME 3. Basically requires a common scripting language. setbg used Perl, background.py Python. For kicks, I decided to do this one in bash.
  5. Only selects pictures to display. This was a little tricky. I don't know of a native GNOME command that says this is a picture or that is not a picture. I cheated on the previous requirement a bit and used the identify command from the ImageMagick package. No defense, except that it's available in every Linux distribution I know of.
  6. Shuts off when you log off, so that there aren't multiple copies running if you log back in. background.py did this. setbg relied on an FVWM command to explicitly kill it. I fudge this one a bit. Basically, my script checks every minute or so to see if its parent (usually gnome-session) is still running. If it's not, the script dies.

As I said, I wrote the script in bash. It's not really a long script, but it comes in at 173 lines because I commented everything. You can download my Gnome 3 Random Wallpaper Switcher script from my software page. It's not licensed, since it's all based on someone else's one-liner. But if you make changes to the script, or find a bug, please let me know about it.

To run the script, put it in your path and type

gnome3_random_wallpaper T1 T2 DIR

Where T1 and T2 are times in seconds, and you want the wallpaper to change at some time T where T1 < T < T2. DIR is the full path to a directory that contains pictures. If it contains some other files, that's OK, the script will skip over them. You and put the command in your startup applications.

I've only tried this with Ubuntu 11.10, as that's the only GNOME 3 desktop I have at the moment, but I don't see why it wouldn't work elsewhere.

Download the official RCJHawk Gnome 3 Random Wallpaper Switcher