Sunday, December 7, 2014

Don't Push My PBButtons

So I wanted to cover something I ran into when first installing and configuring my Debian distro that almost drove me over the edge.  Now as you read on and discover the former source of my misery, you may laugh at its minuteness, but I'm quite particular about configurations and making sure things work exactly as I wanted them to, which as you can probably guess is never easy as you'd like it to be.  However, they (who are they?) say Linux is all about being able to customize everything to your liking. 

The problem was with configuring the G4 PB's eject key to work as you'd eject, I mean expect.  That is, upon pressing the eject button, it would eject any CD or DVD you currently had inserted into your system if any.  Just as if I was still using good ole Mac OS X.  Sounded like a piece of cake.  Every other key on the keyboard did exactly what it said it would do including the volume up, volume down, and brightness keys.  However, whenever a disc was inserted, I had to revert to using the probably better known eject command line tool, which is simple enough, but I'd still like to have the key working as well.

Still being in the infancy of my foray into using Linux (and Linux on PowerPC), I started to research how certain keys were mapped in Debian and other Linux variations on PPC hardware.  I quickly learned certain specific key mappings worked through what software is known as pbbuttons. This runs as a background daemon and can be restarted with the usual restart methods at your disposal. It has a configuration file stored in the /etc directory. Full path is /etc/pbbuttonsd.conf.  Being in the /etc directly, the file will require root/sudo privileges to edit.

The configuration file has a number of customizable options that are way beyond the scope of this post, but as always, I encourage you to peruse the file and make adjustments where you see fit.  It includes such settings as the default values for the brightness values at login/startup, different configurations for when on battery power, and default values for sound and volume.

Anyways, the specific section we were looking for was the [MODULE CDROM] that allowed you to customize which keyboard key to act as the eject key, the delay when pressing that key and which CD/DVD device it was to work with. Right away, I learned from the config file that eject was mapped to the key 161.  Okay, that's nice, but what actual key on the PowerBook's keyboard does that actually map to exactly?  So... more research, which taught me another handy command line utility (honestly, what command line tool isn't?) called xev. Pretty straightforward tool. Just type xev and it will open a new window that intercepts events such as moving a window, resizing a window, or clicking on something, and spits out information regarding that particular event. For example, you can punch any one key on the keyboard and it will print out a number of pieces of information regarding that key.  When I hit the escape key, the utility printed back the following information.

KeyRelease event, serial 46, synthetic NO, window 0x2800001,
    root 0x121, subw 0x0, time 2053168, (639,-2), root:(840,578),
    state 0x10, keycode 169 (keysym 0x1008ff2c, XF86Eject), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False


I changed the keycode value accordingly, but sadly, no go. Long story short, the keycode returned by the utility is not correct and the 161 was actually the value for the eject key as was originally hoped.  So why was it still not working?

Well the only other configuration option that could be the issue was the CD/DVD device it was mapped to. I double checked and it was pointed to /dev/cdrom.  Sounds correct, but I decided to change directories over to the /dev directory to make sure such a device did in fact exist. I ran my alias command for 'ls -alh' to list out the contents of the directory as well display ownership and permissions among other things.
lrwxrwxrwx   1 root root           3 Dec  7 14:15 cdrom -> sr0

Almost right away I noticed in the permissions that the advanced permissions flag (first character in the list of permissions) was set to l, which indicates it is a symbolic link.  So moving my eyeballs further to right, the listing indicated that cdrom was a symbolic link to /dev/sr0.  I immediately updated the conf file to use the actual sr0 device instead of the symbolic link.  I saved the changes and restarted pbbuttonsd.  And what do you know, the key finally worked! Victory!

Here is the full posting of the CD module section if you are interested.
# [MODULE CDROM]
dev_CDROM             = "/dev/sr0"
EjectCDKey            = 161
EjectCDKeyDelay       = 0


In short, you need to map the CD/DVD drive to the actual /dev/[device name] as symbolic links will NOT work. I thought I would share this little tidbit of information in hopes that it helps somebody else someday.  I'll wrap it up here though and continue working on a few other posts I am putting together, including my work on my PowerBook 1400CS, installation of Debian Jessie on a G4 Quicksilver and working with the Clang compiler on PowerPC architecture.  Comments are welcomed!

No comments:

Post a Comment