Spinning the Cube with SLED 10 SP1 on an IBM ThinkPad
Fancy a single keypress to rotate the cube on SLED SP1? On an IBM ThinkPad there some “spare” keys that I had never found a use for until now!
At the bottom right of the keyboard, just above the left and right cursor keys, there are two keys that look like they have a window and an arrow on them. They are not mapped to anything by default but it is possible to configure them to rotate the cube left and right.
Firstly, we need to find out what keycodes these keys are actually sending. There is a very useful tool called xev that allows you to see X Windows events as they happen, including keypresses of course. Open xev from a terminal and the following window should appear.
Ensure this window has focus and then press the key that you want to use to rotate the cube in one direction. The keypress event will appear in the terminal that you ran xev from:
The third line of the KeyPress event shows the keycode as the second entry. In this case 234 is the value. Repeat for the key you want to use to rotate the cube in the opposite direction. This gives 233 for me.
Next we need to assign these keys a proper keysym value. There is a fixed range of allow values, and the ones that seem most appropriate are XF86ApplicationLeft and XF86ApplicationRight. To assign these keys, we use the xmodmap utility. Create a file called .Xmodmap (case sensitive) in your home directory and add the following lines to it:
keycode 234=XF86ApplicationLeft keycode 233=XF86ApplicationRight
This file can then be loaded into your environment by entering the following command at a bash prompt:
X should now know about the meaning of the keys. You can check by running xev again and this time the keysym entry should show you new key assignment.
Now we just need to tell Xgl about the keys. Open the Desktop Effects control panel and go to the Desktop Cube tab. Double click on the “Rotate Left” entry in the list and then press the key that you chose to rotate the cube. Repeat for the “Rotate Right” entry. If you want to be able to take the window that has focus with you, repeat for the “with Window” entries, while holding down the shift key. The result should be as follows:
Once you click close, the cube should spin on your command. If not, or the control panel won’t take your new key assignments, log out and log back in.
For the eagle eyed amongst you, you may also have spotted the <mod3>1 for “Rotate to Face 1”. As pre-Lenovo IBMs don’t have a Windows key we are one modifier down 🙁 However, as I find Caps Lock one of the most irritating features every, I simply use that key instead and assign it as modifier 3! The .Xmodmap entries are:
clear lock add Mod3 = Caps_Lock
Enjoy, and please don’t make yourself dizzy by holding down the rotate left key for too long!!