CrunchBang 11, Apple Extended Keyboard

[If you don’t know who or what these (*) are, check the Glossary page.]

I’m surprised by the things that capture Robofrog’s* attention. I came into the RoboFrog Computing Center (RFCC) this morning and HE’s* hopping up and down all over the place.

“You gotta see this!”

Do I really want to know? It’s too early for this.

“Whatcha got?,” I ask.

“Look. I searched for [apple extended keyboard insert f13] and there we are at the top of Google’s search results.”

Forgive my vanity. There on HIS screen was The Robotic Frog right at the top of the Google search list. Trust me on this one. The first time you see your web site pop up on a Google search is pretty cool. You get a little tingle that runs all the way up your back. And, there’s Lazy Robot close at hand.

I’ve already lost TheFrog’s attention. Looking over HIS shoulder, I see that HE’s entering another search. It’s the same search except he removes the f13 keyword. Now, we’re nowhere in sight. RoboFrog clicks through a couple of pages and there we are on the third search-result page. Lazy Robot is gone altogether (at least as far as we checked…6-7 pages).

This post isn’t about how to do a Google search, but I can see that look on RoboFrog’s face. You know the one I told you about. HE’s frozen in place with knitted brow and I can see the wheels turning. Google knows about us. Google knows about Lazy Robot. So, why did Lazy Robot disappear and why did we drop so far back in the search results? For now, I’ll let TheFrog do HIS thing and I’ll tell you what HE comes up with another time.

Update: RoboFrog left one really important keyword out of his search: Linux! That’s a big oversight. It’s usually HIS first keyword when searching for information to solve a problem on a Linux system. HE got lucky with the f13 thing , but if HE had included ‘Linux’, HE wouldn’t have needed the f13. I’m thinking search is as much art as science.

More Apple Extended Keyboard

Apple Aluminum Keyboard

Apple Aluminum Keyboard (Photo credit: jgarber)

RoboFrog forgot to include ‘linux’ in HIS keywords and fortuitously threw in f13. What if the f13 had not occurred to HIM? Could HE still have assigned Insert to the F13 function key? Sure. The information from the ArchWiki combined with the man pages was enough to fix this problem.

From our previous post:


Reading down the ArchWiki page, we find a few more clues. Under the Media Keys section are the following:

  • ~/.Xmodmap
  • keycode 49 = less greater less greater bar brokenbar
  • “Then run xmodmap ~/.Xmodmap. This command can also go into ~/.bashrc.”
  • xev

It’s rare that we get a perfectly tailored post like the one from Lazy Robot. More often, we get clues like those from the Arch Linux Wiki. All of the clues we need to assign Insert to F13 are contained in those four bullet-points.

First, we need to find the keycode for our F13 function key. We learned from the ArchWiki that xev is a command line utility that displays keycode information. xev is already installed on our systems; we suspect that’s the case with most Linux distributions. On Debian-based systems, it’s included in the x11-utils. So, let’s fire up xev and see what we get.

  • Open a terminal window.
  • Execute xev.
  • Press the F13 key.

In the terminal window you’ll see a description of two events: KeyPress, KeyRelease. Most of the information is of no use to us, but under both KeyPress and KeyRelease we see keycode 191. This agrees exactly with Lazy Robot’s information. So far, so good.

The Dreaded Man Pages

We don’t really need the man pages. With the information from the ArchWiki, xev, and a common-sense guess, we can get the job done. It is a mistake to avoid the man pages, though. They’re difficult to read for Newbies and early HAC (Have-A-Clue) Linux-ers, but the only way to get comfortable with them is to struggle with them a bit. In the case of xmodmap, the man pages have some important stuff.

In a terminal window, type ‘man xmodmap’ (without the single quotes). You’ll get something like the picture above. To navigate the man pages press <spacebar> to page down, <down-arrow> to move down a line at a time, <up-arrow> to move up a line at a time, <b> to move up a page. Let’s look at some important things that we find in this man page.

xmodmap – utility for modifying keymaps and pointer button mappings in X

Man pages are divided into sections. The first, NAME, tells us that xmodmap is a utility. So it’s a program that we’re going to run from the command line or from a script. And, it’s for modifying ‘keymaps and pointer button mappings’. When you press a key on the keyboard, it produces a number. In our case, F13, produces 191. The keymap tells the system what to do with the number 191 received from the keyboard. We need to modify the keymap so that it tells the system to do the Insert function.

Here’s an important point. I don’t know what ‘pointer button mappings’ are. I suspect it’s mapping buttons from something like a mouse, but that’s a guess. I don’t have to understand everything in a man page. There’s useful stuff in them that I do understand and the more I read them, the more I understand.

xmodmap [-options …] [filename]

Synopsis is a pretty important section. It tells us how to use the command; it describes what we are to type on the command line. Anytime something is enclosed in square brackets, […], it means that it’s optional. You may have that thing…or, you may not have it. To execute xmodmap, we type xmodmap on the command line, a space, zero or more options, a space, and a filename…or no filename. That means that we can execute xmodmap without any options and without a filename. Try it. You’ll get some interesting information.

The xmodmap program is used to edit and display the keyboard modifier map and keymap table that are used by client applications to convert event keycodes into keysyms. It is usually run from the user’s session startup script to configure the keyboard according to
personal tastes.

Exactly what we want to do, and something really important. It runs from our startup script. This is why we lost our Insert key when we rebooted (see previous post). The ArchWiki gave us the same information when it said that this can be included in ~/.bashrc.

The following options may be used with xmodmap:


The filename specifies a file containing xmodmap expressions to be executed. This file is usually kept in the user’s home directory with a name like .xmodmaprc.

We know from the information from the ArchWiki that we don’t need any options. We just need the filename of our configuration file (.Xmodmap). The man page recommends a name like .xmodmaprc. We like that suggestion because the rc on the end of the filename reminds us that it’s a configuration file. On our systems, we’re taking the man page recommendation and naming our configuration file .xmodmaprc. Use what feels best to you.

Finally, there is interesting (and potentially important) information in the next section.


The list of keysym names may be found in the header file <X11/keysymdef.h> (without the XK_ prefix), supplemented by the keysym database /usr/share/X11/XKeysymDB. Keysyms matching Unicode characters may be specified as “U0020” to “U007E” and “U00A0” to “U10FFFF” for all possible Unicode characters.

The list of keysyms is assigned to the indicated keycode (which may be specified in decimal, hex or octal and can be determined by running the xev program). Up to eight keysyms may be attached to a key, however the last four are not used in any major X server implementation. The first keysym is used when no modifier key is pressed in conjunction with this key, the second with Shift, the third when the Mode_switch key is used with this key and the fourth when both the Mode_switch and Shift keys are used.


Remember that I said that I would have guessed at Insert for the keysymname? We don’t have to guess, though. The man page tells us that the keysym names are defined in the file keysyndef.h, that they are prefixed with XK_, and that we use the name without the XK_ when we assign the name to a number.

Tip: Do yourself a favor. CrunchBang doesn’t install the locate command. I find this command particularly helpful when trying to find a file like keysymdef.h. No problem; just install it.

aptitude install locate


apt-get install locate


sudo updatedb

To see locate in action: locate keysymdef.h. Now, it’s easy to open keysymdef.h in a text editor and find the definition of the Insert function (XK_Insert). Cool.

The only thing left is to put it all together. We end up with the same solution we had in our previous post:

  • create a configuration text file in our home directory (/home/robofrog/.Xmodmap)
  • Add a line to the file: keycode 191 = Insert
  • From the command line execute: xmodmap ~/.Xmodmap
  • Add ‘xmodmap ~/.Xmodmap &’ to our autostart script (see previous post)

That’s it for the Insert key. Next time, a couple of other tweaks to our Apple Extended Keyboard and we’re finished. The perfect keyboard. Thanks CrunchBang!

More CrunchBang 11

[If you don’t know who or what these (*) are, check the Glossary page.]

At The Robotic Frog, we’re still very much in love with CrunchBang 11 (Waldorf). It has a couple of small warts, but from our point of view, it’s performing brilliantly.

CrunchBang isn’t a Linux distribution that we would recommend to a complete Linux newbie. If you’re brand new to Linux, RoboFrog* recommends Xubuntu 12.04 or Linux Mint. (TheFrog prefers Xubuntu.) If you’re at all comfortable with using command line and a text editor, with a little persistence, you should be able to get CrunchBang to look and feel the way you want. It’s worth the effort.

CrunchBang 11: Apple Extended Keyboard

Wired Apple Keyboard

Wired Apple Keyboard (Photo credit: Jalada and Sefran)

I love the Apple Extended (aluminum) Keyboard. The touch is just right, the keys are large, and they’re well-spaced for my hands. I like the short keystroke too.

Fair warning: RoboFrog’s aunt has the same Apple Extended Keyboard and she hates it…because of the size of the keys and short keystroke. Go figure.

There are a couple of problems with it, though. First, it doesn’t have an Insert key. I use Freemind (mind-mapping software)…a lot. The keyboard command to insert a new node is…you guessed it…Insert. Some have recommended the Enter key on the number pad for this function, but Enter doesn’t do the same thing as Insert. Enter adds a new node to the root node…no matter which node is highlighted. Insert adds a new node to the highlighted node. With Numlock turned off, the Zero-key on the number pad will produce the Insert command. It’s a minor irritation, though, to remember to turn the number pad on and off each time I use Freemind. I prefer to have the number pad always turned on.

The Apple keyboard has several unused keys (in the Linux world): F13-F19. Those function keys are just sitting there taking up space…unless we give them a job. F13 looks like a good candidate for Insert…if we can figure out how to assign the Insert command to it.

Google It!

We talked last time about the power of Google (search engines) and man pages. Here’s how we used those tools to solve our Insert-key problem.

A Google search is almost always the best place to start solving a problem. We’re not the most sophisticated searchers; we keep it simple. First, think about what kind of information you want. In this case, we have an Apple Extended Keyboard; we want to assign the Insert command to an unused key; and, we think F13 (the F13 function key) is a terrific candidate since it’s near the location that we expect the Insert key on a PC keyboard. So here’s our Google search:

[apple extended keyboard insert f13]

As you can see, it’s simply a bunch of keywords identifying the three things we want to know something about: apple extended keyboard, insert, f13. F13 is a wild guess, but it makes the search more specific…and it does make a difference. The solution we finally choose does not come up if we search without the f13 keyword.

The Google search gives a list of links. The best of all worlds is if we get a link that say, “RoboFrog, here’s how to set the F13 key to Insert on your Apple Extended Keyboard with CrunchBang 11 running on BigDog.” That rarely happens. We’d like a specific solution to our problem, but more importantly, we’re looking for clues. One of the links says, “Apple Keyboard – ArchWiki.” This is from the Arch Linux documentation. Your first impression may be that this isn’t very useful because it’s about Arch Linux. We’re trying to configure CrunchBang Linux. That’s a mistake. We used Arch Linux for a long time and know what’s in their wiki documents. Arch-folk are expected to fix their own problems. To help with that, the Arch Linux community put together terrific documentation that they keep on the ArchWiki. I can’t count the number of problems that RoboFrog has solved with information HE* found on the ArchWiki. So, when an ArchWiki link pops up, we pay attention.

What did we find at the ArchWiki? We’re not going to repeat the wiki here. Click the link to see the wiki page. We’ll point out the sections in which we found useful information.

“Function keys do not work” — (ArchWiki)

It’s not that the function keys don’t work. It’s that you have to use the fn shift key to get to them because the keyboard defaults to the media keys. Here’s an example of a problem we didn’t even know that we had. We really like the media keys and we use them a lot. If you want an interesting exercise, try pressing the fn shift key to activate the function keys while, at the same time, holding down both the Control and Alt keys, then pressing F3 (Ctl+Alt+F3). (Experienced Linux-ers know that this is how you switch to a console window.) You have to be a contortionist to do this. Then, you have to press Ctl+Alt+F7 to return to your graphical environment and that’s even more difficult. It would be much better to shift the media keys rather than the function keys. So in this ArchWiki section, is a fix for this problem for Arch Linux…and, it works just fine with CrunchBang.

“Media Keys” — (ArchWiki)

We keep a utility called Tomboy running on all of our machines. It’s a notes application. A notes application is like having a pad of sticky-notes always available. It’s a terrific tool to have when problem solving. We copy and paste the information from the ArchWiki to a ‘sticky-note’ and continue looking for clues. That way we don’t have to keep going back and forth between web sites.

Reading down the ArchWiki page, we find a few more clues. Under the Media Keys section are the following:

  • ~/.Xmodmap
  • keycode 49 = less greater less greater bar brokenbar
  • “Then run xmodmap ~/.Xmodmap. This command can also go into ~/.bashrc.”
  • xev

That’s quite a lot of information and it took only a few minutes to get it. If your new to Linux, this is probably pretty scary stuff. If, however, you know a bit about configuration files, command line utilities, and shell scripting there are a bunch of clues here.

.Xmodmap is a configuration file and it’s located in the home directory (~/). I checked my home directory and there’s no .Xmodmap. That’s okay; it means that I need to create one.

[keycode 49 = …] When you press a key, it produces a number that the computer reads: a keycode. This tells us that we can take a known keycode (49 in this case) and assign stuff to it. We don’t want to play around with keycode 49, but if we can find the keycode for our F13 key, then this is how to assign a function to it. The information for the assignment is stored in our .Xmodmap configuration file. Apparently, that’s not enough, though.

[xmodmap] appears to be a utility program and we have to feed it the information in our .Xmodmap file. There’s another clue that I missed: “This command can also go into ~/.bashrc." Frankly, I’m a little embarrassed that I missed this one. It’s important, as you’ll see later.

[xev] This is the holy grail. It’s a utility program that displays the keycode for a key when we press it. Now we have a way to determine the keycode for our F13 function key.

We learned a lot. Even though this information isn’t specific to CrunchBang Linux (or whatever your favorite distribution) it’s very useful and applicable. The point is that we should scan links from our search even if they don’t appear applicable to our particular distribution. This is Linux and there are more things, from distribution to distribution, that are the same than are different.

Lazy Robot: Apple Aluminum Keyboard on Linux

You know what? Just as we like Robotic Frogs, we also like Lazy Robots (LR)! Going back to our search list, the third entry is for Lazy Robot. We consider that a good omen. Not only did we get a chuckle from the name, but we also got an exact solution to our problem…almost.

If we follow the link to Lazy Robot, we’re greeted immediately with a picture of the Apple Extended Keyboard. We’re in the right place. Lazy Robot does a terrific job of distilling things down to the essentials.

Scanning the page we see that the keycode for F13 is 191 and LR shows us how to assign Insert to the keycode. It doesn’t get much better than that.

That’s it. It will be enabled when you log in. If you want to enable it immediately, type this:

    $ xmodmap .Xmodmap

Magic. You now have an insert key.

Caveat emptor: I can’t tell you how grateful we are to folks like Lazy Robot for sharing information like this. It’s one of the reasons that we do what we do. But…there’s always a ‘but’, isn’t there? But this is only mostly right for our system. That’s not unusual, so be careful.

Here’s how we configure CrunchBang:

  • create a configuration text file in our home directory (/home/robofrog/.Xmodmap)
  • Add a line to the file: keycode 191 = Insert
  • From the command line execute: xmodmap ~/.Xmodmap

RoboFrog and I are doing high-fives. It works perfectly. Finally, I have an Insert key. No more shifting the number pad on and off. That is until I rebooted. Once I rebooted, no more Insert.

“Insert is gone,” says I.

“Did you add xmodmap to the start up script?”

HE* has that look on HIS* face. You know the one. The one that says, “Did you plug it in?” I just want to smack HIM. Actually, RoboFrog is the most patient of Frogs. Maybe the look is my imagination. Not!

“Try running xmodmap again,” says TheFrog.

I do…Magic!…I have Insert again. What does that tell me? That xmodmap must be run every time my system boots (Of course, TheFrog knows that.). No problem. I do that by putting the command in one of my startup scripts. CrunchBang gives me a simple way to do that.

Settings->Openbox->Edit autostart

Add this line to the Openbox autostart configuration file:

xmodmap ~/.Xmodmap &

Now Insert is assigned to F13 every time my system boots. More problem solving and the Apple keyboard next time.