Saturday, October 20, 2012

Revised GNOME3 Wallpaper Switcher

Almost a year ago, I wrote a Random Wallpaper Switcher for Gnome3. Given a directory filled with pictures, every once in a while it randomly chooses a new picture from the target directory and puts it up as Gnome3 desktop wallpaper. You can specify that "once in a while" means every XX seconds, or some random time between XX and YY seconds. And it cleans up after itself when you log off, meaning that the next time you log in you won't have multiple switchers running.

It works pretty well, IMHO, but it does have one small aesthetic flaw: If the picture doesn't fill the desktop, and most of mine don't, the color of the underlying background might be far off from the color of the picture, possibly creating a color clash. Annoying.

Then along came Penguin Pete, who showed me how to use ImageMagick to find the average color of a picture as part of his script for a wallpaper randomizer for Fluxbox. Pete then went on to merge his background with the picture, but in Gnome3 you don't have to do that, as you can set the primary background color directly. A look at man gsettings shows that you can change the background color to, say, solid purple, with the command

$ gsettings set org.gnome.desktop.background primary-color "#FF00FF"

And the rest is easy.

The script is really too long to print here, so, as before, the entire script is available on my homegrown software page. If you don't like the background changing part, I've indicated the lines that need to be eliminated to make the code work without changing the background.

Saturday, July 21, 2012

Updating to Precise Pangolin

I finally got around to updating Hal to Ubuntu 12.04, Precise Pangolin. (No, I never heard of it before, either.) You could have followed the whole thing on Twitter.

Good news: the only thing that broke was the color scheme on my panel bars, which changed to black text on black background. I fixed that right away, and I'm still running a pseudo-Gnome2 desktop.

So, I'm happy with it. Besides, this is an LTS release, so if I don't want to bother updating I can keep it for a couple of years.

Just a bit later: OK, one bug. For some reason the permissions on the directory

$HOME/.config/nautilus-actions

had been reset to 555, meaning I could read or execute files in the directory, but not write to it. This meant that backintime wouldn't back up my disk. Fortunately, backintime has an excellent error log, available from inside the program, that told me what was going on. (Unlike Google-Earth, which is still failing to launch in 64-bit mode after all these years.) I just ran the command:

chmod 755 $HOME.config/nautilus-actions

and all was well.

Saturday, April 14, 2012

A Linux Preview Script

Mac OS X comes with a program called Preview, which displays PDF files as well as images (PNG, GIF, Bitmap, etc.). Linux doesn't have anything quite like it. OK, if you use the Gnome desktop there's something called Document Viewer, usually linked to evince, which reads Postscript, PDF, Djvu, DVI, etc. In fact, it displays Documents better than Preview does.

Unfortunately, evince doesn't display images. For that we have programs like Eye of Gnome, qiv (my favorite), and for image manipulation ImageMagick or the GIMP.

And then there are plain old ASCII files, such as you'd use for source code or LaTeX. For that we could use The One True Editor, or gedit, or some other sort of pop-up display window that lists the contents of a file.

What we want, then, is a program, preferably a command line script, which is given a file name, determines what the file is, and then opens the file using the appropriate viewer/editor. How do we do that, pray tell?

Enter the file command, inherited from Unix. file is pretty useful. For example, suppose I have a JPEG file, but for some reason it has been named x1, without the extension. file figures it out pretty fast:


$ file x1
x1: JPEG image data, JFIF standard 1.02

And it will work on most standard Linux file types.

Given this, it's fairly easy to construct a script which takes a look at one or more files, determines the file type, and picks out the approriate file viewer. My script is below. I've called it gnuview. You invoke it from the command line:


$ gnuview file1.txt file2.png file3.dvi file4.bmp

and all of these files pop up on your screen, each launched using the appropriate program.

A few notes:

  • The list of file types is not by any means complete, though I think I hit most of the major ones. If the script doesn't know how to handle a specific file type, it prints out a message on standard error. It's fairly obvious how to add different file types.
  • I dumped my favorite programs (qiv and emacs), in favor of programs that are installed by default with most Linux distributions (eye of gnome, gedit). (qiv doesn't read bitmap files, anyway.) Feel free to change the defaults to your favorite.
  • Error messages? We don't need no stinkin' error messages!
  • Finally, the cascading tree structure of if statements is just annoying. This should probably be rewritten using some kind of case construction, but I didn't bother to figure it out.

No warranty for any of this, of course, and not even a license except for the Creative Commons Disclaimer down at the bottom of this web page. If you come up with a version of this code, put it in the comments or put a link to it there.


#! /bin/bash

# This is an attempt to mimic the behavior of Apple's OS X Preview
#  program.  We determine the type of the file and then use the
#  appropriate command to open it.

# Some defaults.  Change as you see fit:

# ASCII files.  Note that gedit must be invoked in standalone mode

GNTXT="/usr/bin/gedit -s"

# Picture viewer (eog reads more files than qiv, so we'll use that)

GNPIC=/usr/bin/eog

# Postscript/PDF/DjVu/DVI viewer:

GNPDF=/usr/bin/evince

# Read the command line, and scroll through each file type:

for thisfile
do

#   If the string says ASCII anywhere, do this, which should get
#     LaTeX source, source code, etc.

    file $thisfile | grep 'ASCII' 2>&1 > /dev/null
    if [ $? -eq 0 ]
    then

        $GNTXT $thisfile &

    else

#   Maybe it's a document (Postscript/PDF/DjVu/DVI):
#   (I wan't sure about the "or" construct, see the first comment in
#   http://www.cyberciti.biz/faq/searching-multiple-words-string-using-grep/)
        file $thisfile | grep 'document\|DVI' 2>&1 > /dev/null
        if [ $? -eq 0 ]
        then
            $GNPDF $thisfile &
        else

#   Or maybe it's an image
            file $thisfile | grep 'image\|bitmap' 2>&1 > /dev/null
            if [ $? -eq 0 ]
            then
                $GNPIC $thisfile &
            else

#               And if we haven't figured out the type yet,
#                leave a nice note:
                FTYPE=`file $thisfile | awk '{print $2}'`
                echo Cannot handle file $thisfile, type $FTYPE  > /dev/stderr
            fi
        fi
    fi

done


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

Friday, November 25, 2011

I For One, Welcome Our New Canonical Overlords

I've just updated Hal to Ubuntu 11.10, Oneiric Ocelot.

I don't regret it — quite. It is however, going to take a long time to get it to where I want it to be, e.g., something that looks like my old Gnome 2 desktop.

Why not just change to a distribution that still uses Gnome 2? Because Gnome 2 is going away. openSUSE 12.1 is out now, and it uses Gnome 3. Fedora uses Gnome 3. You see where this is going.

So this post, and probably many more, will be rough notes on how to make Hal's desktop look like it did before. I'm not going to go cursing Mark Shuttleworth. (I've learned from the last ten years of cursing Dan Snyder — it just doesn't work.) Ubuntu is, for now, a useable distribution, and I can, eventually, tweak everything to get to where I want to go. That's the beauty of Linux.

Besides, it makes for a lot more blog posts.

Hal, I should point out, is just fine. He can still do fancy LAPW electronic structure calculations faster than the Cray XMP of my youth, and he still reads my email and browses the web with aplomb. He can still develop code with Emacs. He just doesn't look very good right now, but we're dealing with that.

Eventually I'm going to update the spouse's computer, Harlie. When I do that I hope to do one of those step-by-step guides, which will be more coherent. But for now, think of this as a set of Google Notebook entries. Oh, wait, Google pulled the plug on that and is now moving all my files to Google Docs.

Oh, well, let's just get on with it.

Oneiric comes with the brand-spanking new Unity desktop, which, as I said once before, is so like Mac OS X that it comes with a lawyer to deflect lawsuits from Cupertino.

I was wrong — it's worse than Mac OS.

Like OS X, Oneiric comes with a dock, or maybe it's called a Launcher. On the Mac the dock can be moved, it can change size, it can automatically hide if you don't want it on the screen, and it's quite easy to drag applications over to it. In Oneiric the dock is fixed on the left, you can't change its size, it only hides itself when a window pushes it away. You can drag applications onto the dock, but it seems harder, somehow, than on the Mac — that's my subjective point of view, of course.

So I quickly changed over to Gnome 3.2. Well, not quickly, because Gnome isn't installed in Oneiric. And since my 11.04 distribution used Gnome 2, the upgrade process ripped out all of that software as well. So one must install all things Gnome. I used to do this with Synaptic, but, guess what, Synaptic isn't installed either.

So first open up a terminal window. Can't find a terminal? Click on the Dash Home icon at the top of the dock, click More Apps, click to show all of the installed apps, scroll down and find the terminal, and click it. (First you might want to drag the icon over to the dock, for later use.)

With the terminal finally open, you can install Synaptic by typing

sudo apt-get install synaptic

You could then find synaptic in the Dash Home menu, but it's easier to just say:

sudo /usr/sbin/synaptic

and go from there.

Once in synaptic, search for Gnome and install it. You'll probably want to install some Gnome themes, etc. While you're there, also install the Gnome Tweak Tool as well.

Then log out. When the login screen appears, click on the little gear by your name and select Gnome Classic (no effects) or whatever other version of Gnome you desire.

It's OK to throw up your hands and go off to figure out Unity at this point. Really.

Because when you log in, you'll see something that looks only vaguely like your old Gnome desktop, sort of like the difference between Darrel Hammond and Bill Clinton. There's a menu on the top, but it only says Applications and Places. And the clock seems to be stuck to the middle of the upper panel, neither movable nor removable. Also the Theme will be hideous. You can fix that, sort of. Click Applications/Other/Advanced Settings, (that's the Gnome Tweak Tool), click Theme in the box that pops up, and play with the Window Theme and the GTK+ Theme until you get something you like. One of my missions is to figure out how to edit the theme colors, to create what used to be called a Custom Theme. No luck, so far, but if I find it I'll let you know.

You should have two toolbars, one at the top and one at the bottom of your window. You add things to these bars, change their properties, etc., as before, but instead of just right-clicking on the bar, you have to hold down the Alt key and right-click. That's easy enough.

You'll also have to search for some of your options. The old Gnome menu used to have a Preference section and an Administrative section. Those functions are now hidden in the Applications menu, under Other and System Settings, apparently with neither rhyme nor reason. Play around with that until you're comfortable in finding things.

Finally, for now, go to Things to Tweak After Installing Oneiric Ocelot 11.10, and see what's useful there. And don't forget 10 things to do after installing Ubuntu 11.10.

More as I find more stuff.

Sunday, May 30, 2010

Return With Us Now to the Thrilling Days of Yesteryear

I'm not very good at doing disk backups.

OK, let's be honest: I'm terrible at doing disk backups. Oh, back in the day, every once in a while I'd copy as much of the disk as I could onto CDs or DVDs. But that takes a lot of time, and, as disks become larger while DVDs don't, requires a lot of picking and choosing to figure out what goes where.

To be fair, I haven't needed to. In all the years I've run computers here at home, I've never had a disk crash that lost data, even after our most serious disk mishap. So not having a backup hasn't been that big a problem. (Insert your favorite ominous foreboding music here.) Anyway, backups are a pain in the neck.

My view of backups has changed, though, primarily because they're so much easier now. Easiest, of course, is Apple's Time Machine. Plug a second disk (USB, Firewire, internal, if you've got such a thing) into your Mac, let it format to Apple's HFS format (or not), and start Time Machine. Tell it which directories you want to back up, and it will do that, every few minutes. Then you can actually scroll back through time (Tardis sounds not included) and pick out a file you might have deleted a year ago — assuming you were running Time Machine back then. It's an extremely neat and easy-to-use utility, and takes the pain out of doing backups, as long as you remember to leave the external disk plugged in, if that's what you've got.

Then, last week, Office Depot ran a sale where you could get a Terabyte Verbatim USB disk for $79.99 + tax. I bought three, one for Hal, one each for the college students.

Now the disk comes with Nero backup software for Windows (taking care of student I), and Apple's got Time Machine (taking care of student II). But what about poor Hal, stuck in Linux?

I called up the Synaptic package manager and typed backup in the search box. That brought up, among other things, a package called backintime, which is a front-end which uses the utilities cron (to schedule backups), diff (to find which files are changed), and rsync (to copy files that have changed to the backup disk). Perfect. I installed the program — actually both backintime-common, the guts, and backintime-gnome, the graphical front end, then went to get the disk.

Problem: Verbatim formatted the disk to the lowest common denominator, FAT32. This is not suitable for low-volume backups, because it does not allow multiple hard links to the same file. What backintime does, you see, is create a copy of your chosen disk directories every time you schedule a backup. The trick is that unchanged files are hard-linked from one backup to the next, taking a minimum of space. Only the changed files are stored in multiple copies. Since the FAT format doesn't do multiple hard links, it can't do the trick, and so we need to reformat the disk to a better file system.

So I installed gparted from Synaptic, launched it (using sudo gparted), and formatted the Verbatim disk to ext3 format.

Second problem: If you just plug a USB disk into a Ubuntu box, it auto-mounts, but is usually only accessible to the user who did the mounting (to be fair, I haven't tried this with a USB ext3 disk). That's unacceptable in a backup system that needs to be accessible to everyone. So we have to set up /etc/fstab. To reflect this. Ideally, we'd add a line which looks something like this:

/dev/sdd /backup ext3 errors=remount-ro 0 2

(Note added after the fact: The last entry on this line should indeed be a 2, not a 1 as previously listed. This this tells fsck to check this file system after any file system with a 1 in the last column. The only file system with 1 there should be the boot partition. Everything else can be a 2, unless you don't want fsck to look at the file, in which case you put in a 0. Got that?)

create a directory entry /backup, and then doing

mount /backup

would load up the disk drive.

However, since you usually have multiple USB ports on your system, there's no guarantee that this disk is going to always get /dev/sdd as its port. The solution is to use the ext3's UUID, which was created when gparted did its thing. You find the UUID with the command:

sudo blkid
[sudo] password for hal:************
/dev/sda1: LABEL="PQSERVICE" UUID="0A72323D72322DB7" TYPE="ntfs" 
/dev/sda2: LABEL="SYSTEM RESERVED" UUID="CCA811C2A811AC48" TYPE="ntfs" 
/dev/sda3: LABEL="Gateway" UUID="7E143E7F143E3A8B" TYPE="ntfs" 
/dev/sda5: UUID="2eec3fff-73d2-419c-8a3c-b92733d46da2" TYPE="swap" 
/dev/sda6: UUID="f3781533-d891-46e1-b9f0-839e8a538d35" TYPE="ext4" 
/dev/sdb1: LABEL="Verbatim" UUID="9deee42d-539b-45c5-8683-e95f889c1792" TYPE="ext3"

Verbtim is how I labeled the disk partition of the USB drive, so that's the UUID we want. Fill out the line in /etc/fstab as:

UUID=9deee42d-539b-45c5-8683-e95f889c1792 /backup ext3 errors=remount-ro 0 1

and we're ready to go. Note that this will automount so that everyone can read it every time the disk drive is plugged in and turned on.

That settled, setting up backintime is easy. You can specify the directories you want to back up, and the file types (say, those ending in ~ or .o) and directories you want to exclude. You can then select a backup time interval: minutes, hours, days, weeks ... Once you have a set of backups, you can use the graphical interface to look through your files of any snapshot, and restore a file that was deleted or moved on your main system, or copy it to another location if you like. It's very nice and easy to use.

You can see your backup schedule using crontab:

crontab -l
@daily nice -n 19 /usr/bin/backintime --backup-job >/dev/null 2>&1

Note the @daily there. That means the backup will start every night at midnight, and it's the only choice backintime gives you if you select a daily backup. This is unsatisfactory for me, as someone is frequently using the computer on and after midnight. So I used crontab -e to edit this entry, changing it to
0 3 * * * nice -n 19 /usr/bin/backintime --backup-job >/dev/null 2>&1
which launches the backup at 3am. backintime accepts this, but note that every time you change your setup it will reset the time to @daily. Just watch it.

Anyway, now I have a disk backup. And since I've never had a major loss of disk data from one disk, having two disks copying the data should mean that it can never, ever, ever happen, right? (Insert even more ominous and foreboding musing here.)

Sunday, May 23, 2010

Ubuntu 10.04: Update Notification Icon

One thing that doesn't seem to be present in Ubuntu 10.04 is the little notification icon that shows up on your panel when the update manager has found programs to install. If there is some notification I haven't seen it.

Apparently this has been going on since 9.04, but for that version of Ubuntu I was running IceWM rather than Gnome as my window manager and so missed it. But Watching the Net didn't, and shows the way to restore the Update Icon by turning off the update notifier, whatever that is.

Apparently once the new improved update notifier (which I've never seen in action) is turned off the old style notifier kicks in. This is in the province of gconf, that all-seeing, all-knowing application that tells other programs what your likes, wants, and needs are — sort of like Facebook.

So to turn off the new-improved version and go back to the thing that works, open a terminal window and type (or cut and paste):
gconftool -s --type bool /apps/update-notifier/auto_launch false

Alternatively, launch gconf-editor, click on the + sign next to apps, scroll down to find update-notifier, click on that, and then uncheck the box that says auto_launch.

Either way, you're done, and the old icon will come up the next time you have an update available.

Thursday, May 20, 2010

Ubuntu 10.04: Remove the Chat and Mail Icons but keep the Volume Control

I don't chat. I can find my email on my own, thanks. But I do like the volume control up on the panel. Thanks to Short IP Recipes for the fix: Remove the indicators from your system:

sudo apt-get remove indicator-me indicator-messages

Log out, log back in, and voilà!

Monday, May 17, 2010

The “Right” way to move buttons in Ubuntu's Gnome

Apparently using gconf-editor or directly editing the file $HOME/.gconf/apps/metacity/general/%gconf.xml to move the control buttons back where they belong is not the Correct Way to Do It and Will Cause Problems in the Future. Or so it says here (see #3).

Despite there always being More than one way to do things, we here at Linux & Things are always willing to show you The One True Way.

So here we go. Apparently, in the New Ubuntu Gnome, only the Ambiance, Radiance and Dust themes have buttons on the left. All the others still have buttons on the right. So if you want a Right-Wing Ambiance, say, you pick a Right-Wing Theme and edit it to Look Like Ambiance. Got that?

That's right. To make Ambiance with buttons on the right, edit, say, the New Wave theme and make it look like Ambiance:

  1. Click System > Preferences > Appearance
  2. Select New Wave and click Customize
  3. Click the tabs Controls and Window Border and select Ambiance for each.
  4. Click Icons and select Ubuntu-Mono-Dark
  5. Close

But don't forget The Other Way to Do It, for use when Ubuntu arbitrarily moves New Wave's buttons to the left.

Friday, May 14, 2010

Today's Ubuntu Annoyance: The Buttons are on the Left

In 10.04 using the Gnome desktop, the buttons to minimize, maximize, and close a window moved from the right side of the screen to the left. Being right-handed, it feels unnatural to have the buttons on the left, so I want to move them back. Trevor has the solution:

  1. Open gconf-editor, either from the command line or by pressing Alt-F2 and typing it in the box.
  2. Click on the + sign next to Apps.
  3. Scroll down on the left-hand-side until you find metacity. Click on the + beside it.
  4. Click on the folder labeled general.
  5. On the right-hand-side, find the label button_layout. Double-click it.
  6. In the box that appears, type :minimize,maximize,close. Order is important. The colon divides the left-hand side from the right. So if you wanted the close button on the right and the rest on the left, you'd type minimize,maximize:close.
  7. Click OK and you're done.

If you want to edit things by hand, it looks as though the appropriate place is the file $HOME/.gconf/apps/metacity/general/%gconf.xml, which should look something like this:

<?xml version="1.0"?>
<gconf>
 <entry name="button_layout" mtime="1273837457" type="string">
  <stringvalue>:minimize,maximize,close</stringvalue>
 </entry>
</gconf>

Although there may be other entries between the gconf lines.

Thursday, May 13, 2010

Ubuntu 10.04: gnome-screensaver and switch user

Bugs. Why does it always have to be bugs?

Anyway, with the advent of New Hal, my wife and I use the same computer. She doesn't do much more than check email, check Snopes to refute emails from the clueless, and make plane and hotel reservations. Things like that, she's not a heavy computer user. It's not likely that she's going to be running a 16 atom Quantum Espresso simulation in the background, unlike some people I know.

So it's OK for both of us to use the same box for most things. The idea way to do this is with the Switch User option, which works really well once you know each other's passwords and know about Ctrl-Alt-F7/Ctrl-Alt-F8. (Don't try this at home unless you have a really strong marriage.) So we both stay logged on, and use Switch User to get back and forth between our accounts.

Except that when you're both logged on all the time, you don't want the monitor running all the while. It wastes power, and it's annoying to walk in to the room and see the thing lit up in the middle of the night.

The default option is to use gnome-screensaver, which seems to be installed automatically with 10.04 and launches when you boot. Just set the options the way you want it and you're good to go.

Except — of course there's an except, why do you think I'd be writing otherwise — there's a bug. Multiple reported bugs, actually. There's 478253, 555870, 546578, 561538, and, lest we forget, 535467. All of them report more or less the same thing: when you use Switch User, sometimes the screen goes black.

A workaround is to run xgamma -gamma 1.0 when the black screen occurs. This is rather difficult because the screen is, in fact, black, and unless you're very lucky you won't be at the right spot on the screen.

So, following a suggestion in the comments to 561538, I ripped gnome-screensaver off the computer and installed xscreensaver. Set it up on both accounts, then went out to work on the lawn.

When I came back, GDM was cheerfully restarting itself every 2-3 seconds, complete with endless be-bop sound every time. I suspect that this is because the two instances of xscreensaver were competing with each other.

I'm not sure that's the case, but I worked under that assumption and killed the screen saver in my account. That fixed the problem, so I've left things at that. Now I just remember to switch the screen to my wife's account when I'm done on the computer.

Thursday, October 30, 2008

Choosing Default (or null) Applications

I've been ripping a lot of CDs lately, to play on the Focus's MP3 player while I'm making the five-hour drive between Durham and Bowie East. A CD full of MP3 files plays a lot longer than an audio CD. My preferred application for ripping is grip.

Ubuntu 8.04 (Hardy Heron) has some defaults built into its gnome desktop. In particular, if you insert an audio CD, it assumes you want to play it and brings up rhythmbox, even if you already have grip running!

Annoying. And, as has been noted by others, in Ubuntu 8.04 it’s surprisingly hard to change default applications to something of your liking.

What do I want to happen when I pop in a CD? Nothing. That's right, nada, nichts, zip, /dev/null, nothing. This is Linux, right? I'll decide which program I want to run, when I want to decide it.

The aforementioned post has one suggestion: going into /etc/gnome/defaults.list and editing the appropriate lines. So I did. Since I didn't want anything to automatically happen when I inserted a CD, I deleted the lines reading:

x-content/audio-cdda=rhythmbox.desktop
x-content/audio-dvd=rhythmbox.desktop
x-content/audio-player=rhythmbox.desktop

It worked, too. When I put in an audio CD, rhythmbox didn't appear. No, sound juicer, another CD ripping program, popped up, again in parallel with my already running copy of grip.

Now I've used sound juicer. I like sound juicer. Sound juicer is no John Kennedy, but it's a good program. I just like grip better. So what to do?

The solution, my friends, lies within nautilus, Gnome's file manager. Well, somewhere in there, I can never find the appropriate menu option. However, if you try to bring up nautilus from the command line and use file completion, you find:

nau
nautilus                  nautilus-connect-server
nautilus-autorun-software nautilus-file-management-properties
nautilus-cd-burner        nautilus-sendto
$ nautilus

nautilus-file-management-properties sounds promising, so let's run it. That brings up a box that looks like this:

nautilus preference box

Two options are apparent: If you click on the box next to CD Audio, you can select the option Do Nothing. Or, you can click the box that says Never prompt or start programs on media insertion. That's what I did. And, when I insert a CD into my computer ...

Absolutely nothing happens.

Until I want it to happen.

\

Note: This works in Gnome. KDE doesn't use nautilus, so there's another program, I don't know what, to do that. Other desktops, e.g. FVWM, don't usually try to impose default behavior. You have to ask to to something special. Also, this is probably a Ubuntu default, not a general Gnome default. So YMMV, but that's the wonderfulness of Linux.

Sunday, June 08, 2008

The Annoyances of Upgrades III: I Want My Music Programs

Yet another annoyance in the upgrade to Hardly-a-Heron: the distribution no longer includes XMMS, one of the better light-weight music players. It includes something called XMMS2, but after a few minutes of playing with it I couldn't figure out how to get it to play one song, you, know, like:

xmms2 House_of_the_Rising_Sun.mp3

something that's simple in xmms. Fortunately, there are not one, but at least two sites that take you through the process of installing the original xmms from source, including all the development packages you need to install.

And Heron still doesn't have an MP3-enabled SoX. Fortunately, once you've installed all the development packages mentioned above, the installation of sox is pretty straightforward.

I have to admit, I'm getting Grumpy, I'm getting Grumpy, all the time.

Saturday, June 07, 2008

The Annoyances of Upgrades II: Things You Put in the Cup Holder

More stuff that annoys me about the Gnome Upgrade: when I put a CD or DVD into the cupholder, I most likely don't want to listen to music or watch a movie just then. Yet under Ubuntu Hardy Heron and Gnome 2.22.2 (when you don't know who to blame, blame everybody) a music player automatically pops up.

Of course, this is Linux, so there's gotta be a way to fix this, and there is. It took a while to find, but it's in the Nautilus File Manager. Once you know that, click on Edit => Preferences or run nautilus-file-management-properties from the command line, and click the Media tab. Then edit the various options as desired. Regrettably you don't seem to have a lot of choices. You have Gnome's default program, and “Ask what to do” option, “Open a Folder” and “do nothing.” No option to change e.g. the Camera program from F-Spot to gThumb, though you can do that using gnome-volume-properties.

Gee, you'd think an advanced desktop environment would put all of these things in one nicely labeled place, wouldn't you? Apparently only if the environment is sufficiently advanced.

Grump, Grump

Saturday, May 31, 2008

The Annoyances of Upgrades: Gnome Default Camera Program

Last week I finally updated to Ubuntu 8.04 (Hardy Heron). Today I tried to download pictures off my camera. I'd previously set the default camera program to gThumb, but, in either Ubuntu or Gnome's infinite wisdom, the default camera handling program had been reset to F-Spot.

Now I'm sure that F-Spot is a nice program, full featured, and wonderful to use. However, it's not something I want to deal with on a Saturday morning when I'm getting ready to take Prom Pictures.

This is what I get for using software-for-the-masses, I know. (Somewhere, Penguin Pete is laughing at me.)

This leaves me with two options: I can learn how to make F-Spot do what I want it to do, or I can change the preferences for Gnome so that it knows to use gThumb when a camera's connected.

If you picked (1), you don't know me very well. I prefer to sticking-with-what-I-know until what-I-know becomes so unwieldy that I throw up by arms in disgust. Unfortunately, that happened a year or so ago when I decided that FVWM was just too ugly, and it was easier to start using Gnome than to really work at prettying up FVWM. There are lots of things about Gnome that I don't really know yet. In particular, how to change the default camera application. Yes, I'd done it once, but I'd forgotten to write it down.

That's what this blog is for: to write things down that I'd otherwise forget (except I forget to write it down). So after a brief web search, I found the answer: the way to set the camera options is not, as you might think, in Preferred Applications (gnome-default-applications-properties from the command line), but Removable Drives and Media Preferences (gnome-volume-properties). From there changing the default is easy.

Not that an upgrade should change my default.

Grump

Friday, December 28, 2007

Gnome, Gnome on the Range

I'm playing with switching window managers. For maybe ten years I've been using FVWM in one or another of its incarnations. I'm thinking it might finally be time to change to a more “modern” window manager. No particular dissatisfaction with FVWM, but I'd like a different look to the screen. It's sort of in the same thing as my Comcast/Verizon switch, except that no one's offering me a TV.

Since the default Window manager for plain-old-vanilla Ubuntu is Gnome, let's try that. It's as simple as changing your session before you log in.

Of course, that gives you plain-old-vanilla Ubuntu Gnome. I like to make my desktop look like my desktop, not some office stiff. So modifications are necessary. Most are based on my belief that a Window Manager must perform tasks that I want it to do, not the way favored by some group of software designers, no matter how talented. In FVWM these modifications were performed in the $HOME/.fvwm/.fvwmrc file. In Gnome most things things can be done from menus, to wit:

  • Launch the applications I want opened on startup: Gnome does this in the Systems => Preferences => Sessions.
  • Move applications onto another part of the desktop: With FVWM, you drag across the screen. Gnome doesn't have a virtual desktop, it has several workspaces. You can move programs between workspaces by dragging them along in the Workspace switcher, which is usually down on the right-hand side of the screen.
  • Add applications to the Menu: and generally muck up the way information is presented. With FVWM you edit the menu. In Gnome the Menu edits you. OK, not really. Right-click on Applications and select Edit Menus. When you add an application, you can also select an appropriate icon by clicking on the default icon in the application editing box.
  • Change the wallpaper randomly: This isn't a property of FVWM, but I wrote a Perl script to do it. In Gnome get the Python script background.py, and launch it on startup. What it doesn't do, at the moment, is change pictures at random intervals. That shouldn't be too hard to fix. Learning Python is one of my software goals for 2008 in any case.
  • Make programs appear in assigned workspaces: That is, I want Thunderbird to come up in workspace 1, Firefox in workspace 2, Emacs in workspace 3, etc. One application per workspace, and I can switch through them with ctrl-alt-arrowkey. To switch between windows in the same workspace, you use alt-tab.

    This isn't a part of Gnome, unfortunately. However, since this is Open Source, there are ways around it. The solution of choice here is Devil's Pie, available from the Ubuntu repositories. Install it, make sure it's running when you log in (see above), and create a directory $HOME/.devilspie that contains files like this:
    $cat ~/.devilspie/firefox.ds 
    (if
    (is (application_name) "Firefox")
    (begin
    (set_workspace 2)
    )
    )
    
    which assigns Firefox to workspace 2. Note that this doesn't launch Firefox, you have to do that yourself. When you do launch Firefox, however, it will appear in workspace 2. (Note: I originally did cut-and-paste from a published tutorial. That led to the strange Unexpected token encountered: 226 error, which apparently is because the examples use Unicode quotation marks. If you get this error you might as well type in the script by hand, it's short in any case.

There are undoubtedly a lot of tutorials out there on how to use Gnome efficiently. They're probably useful. However, remember that this is software we're talking about: back up everything you want to save, then play around. If you hopelessly frak something up, go to your backup and start over. For gnome, the simplest backup is just:

$ cd
$ mv .gnome .old_gnome
$ mv .gnome2 .old_gnome2
$ cp -r .old_gnome .gnome
$ cp -r .old_gnome2 .gnome2

which preserves your original files. Now restart Gnome, and play around. If you find you're hopelessly lost, just:

$ rm -fr .gnome .gnome2
$ mv .old_gnome .gnome
$ mv .old_gnome2 .gnome2

and you're back where you started.

Saturday, August 27, 2005

Finding the Right Lights to Turn Off

A few weeks ago, we did a bit on how to Turn Out Lights under FC4, i.e., shut off programs that start on a default system on boot-up, but you don't need. But which programs can you safely turn off? Fedora Weekly News has tells us in Which Services Can I Disable? This goes through many of the programs you see with the command

system-config-services

It doesn't cover all of the commands I found, and it has some that don't appear on my computer, but it's useful none-the-less.

Hey Windows Users! You undoubtedly have some programs running that you don't need, as well. Check those running in your Startup menu for starters. You can also disable lots of other useless programs. (I'd say Windows is a useless program, but then, you know, I'm not entirely rational on the subject.) Run Google and search for "remove useless Windows programs" or similar strings. You'll find a bunch of stuff.

Monday, August 08, 2005

Turning Off the Lights

Sometimes, after you set up your computer, you find that the default installation is running things that you don't really need. For instance, this computer is currently running some kind of Bluetooth server. I don't own a bluetooth device, so that's useless.

I got a reminder about how to fix these kind of things from this Boot Fedora Faster Howto article. OK, there are things in there that I'm not going to do, since I don't plan to recompile the kernel any time soon. (Thanks, Dave. Don't mention it, Hal) However, you can "turn off the lights" in rooms that you aren't occupying at the time. In Gnome, according to the article, you click on Desktop->System Tools->Server Settings->Services. If you work from an Xterm, the corresponding command is

system-config-services

You'll be asked for your root password, and then you'll get a menu of system services. A check-mark indicates that the given service will start on boot, so uncheck those you don't need. To stop a service right now, right-click on it and select "Stop" from the menu.

Doing this increases system security, since you aren't running things you don't need, and should speed up your computer, since you don't need to start up useless programs on boot.

Thursday, January 01, 2004

Preferred Applications

A quick note because I'm always forgetting this stuff: I use Ximian Evolution as my mail reader, and MozillaFirebird as my browser. Evolution is a Gnome Desktop application. So, to get a clicked hyperlink in Evolution and to pop up in a new tab on Firebird, the following needs to be done:

  1. Launch the Gnome control center (gnome-control-center from an xterm)
  2. Click on Preferred Applications
  3. A window will come up. Click on the Web Browser tab, and then Custom Web Browser
  4. Edit box as you want and click Close.

My "Custom Web Browser" is a little file called newfire, which looks like this:

#!/bin/sh
# From http://vroop.com/archives/000020.html:
# open URL in new process if there isn't one, otherwise open URL in a new tab
firebird -remote "ping()" &&
firebird -remote "openURL($1, new-tab)" &&
exit 0
# if we're here, open a new process.
firebird "$1" &

As the comments say, if Firebird is open this opens the link in a new Firebird tab. Otherwise, clicking the link opens Firebird.

Happy New Year everyone.