Damn you, Saint-Exupéry!

The Ubuntu Linux distribution is putting a lot of efforts into streamlining the interface and provide a greater user experience. While there’s clear progress, there are a number of things that are still really missing. The guys at Gnome and at Ubuntu are maybe taking the motto perfection is not when there’s nothing else to add, but nothing else to remove a bit too seriously. Every release shows more and more features but less and less user configurability.

Well, to be honest, I have always found my way around those limitations by hacking directly configuration files, the gconf-editor registry-like thingie, and writting scripts to set automatically configurations for which there were no other way—or just not documented, which is the same as far as I am concerned.

Amongst the extra thingies, there are many keyboard shortcuts, but not all of them are configurable. For example, if there’s a way from Gnome to configure which keys you want to use to control LCD or keyboard brightness or to display power information, it’s pretty damn well hidden. On my Dell mini, there’s a nice key with a battery icon on it. If I press it, Gnome displays in the OSD a concise battery status. But on my macbook pro, there’s’nt such a key and I have no way of telling Gnome (from Gnome itself) to use the F4/Gauge key to act as the Show Battery key.

Reading tutorials, I found ways to remap the Gauge Key to the XF86Battery key (that’s its name for XFree86), but while xev (a X event reporting tool) does detect the Gauge key as the battery key… nothing happens.

So of course I googled more. And some more. And more. Each fix seemed as hacked and brittle as the next one, all susceptible to break at next update. After a while reading on the Linux ACPI subsystem, I finally decided to write my own script.

As last week‘s script, you will need to install a couple of dependencies if they are not already there:

sudo apt-get install libnotify-bin acpi

And this should provide the interface to send messages to the OSD and get information from the power interface. You need to have acpid configured correctly also.

So here’s my script:


#needs acpi

# get -a adapter and
#     -b battery
#     statuses
statuses=$(acpi -a -b | tr '\n' ! )

if [ "${statuses}" == "" ]
    notify-send \
        --urgency=low \
        --icon=notification-battery-empty \
        "Power Information" \
        "No power information?"
    level=$( echo $statuses | tr '!' '\n' | grep -i battery | cut -d\% -f 1 | cut -d, -f 2)
    adapt=$( echo $statuses | tr '!' '\n' | grep -i adapter | cut -d! -f 2 | cut -d: -f 2)

    if [[ "$adapt" =~ "on-line" ]]

    level=$( printf "%03d" $(((level+5)/10*10)) )

    notify-send \
        --urgency=low \
        --icon=notification-battery-${level}${adapt} \
        "Power Information" \
        "$(echo $statuses | sed -e s/"%, "/'%\n'/g -e s/\!/'\n'/g )"

You just go to system→preferences→keyboard shortcuts and add a new custom shortcut to the script (you have to use a fully qualified path such as /where/you/put/the/script/show-power-status.sh to get the script to launch properly.

Now pressing the Gauge key (or whichever you chose), you see OSD-like messages giving you the status:

Should you rather see:

It’s either because there is no ACPI information reported by ACPI (at least one of my desktops does that) or for some reason there are neither batteries nor adaptors detected/reported by ACPI.

* *

As my boss say, if it’s not documented, it might as well not exist. Ubuntu provides more and more gadgets to the interface but at the same time removes and hides more and more configurability. Some systems, like the power management event system that prompts the OSD to display messages like “AC plugged, now charging” (or whatever) is absolutely not documented. The setting that declares the XF86Battery key as the shortcut is nowhere to be found (true, I haven’t grepped my entire drive), and there are no obvious ways to set a different key.

I think it’s Saint-Exupéry (a sententious fellow, methinks) that coined perfection is not when there’s nothing else to add, but noting else to remove. Einstein warned us about that as well: he said to keep things simple, but no simpler than necessary. I think the guys at Gnome should meditate that over for a while.

If you add a feature, you add the configuration dialogs, the configuration files, not just defaults values hidden away in the executable, even if the default values are somewhat sensible. Don’t take the users for stupid. They’re not.

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 )

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

%d bloggers like this: