Making Crikey! work on various window managers

Window Manager Key Bindings

The most common use for crikey is to bind it to a key in your window manager, so a string gets inserted whenever you hit a key in a window anywhere. Different window managers have different procedures for doing this.
Here are instructions for a few: ... KDE ... xfce ... openbox ... icewm ... fvwm ... afterstep ... Any (using Keylaunch). Gnome people look here.

KDE

A full and detailed writeup is coming soon, but here's the short answer: use the built-in Menu Editor to add a new menu item (doesn't matter where you put it) for a new command which calls crikey yourstring, (you might want to add a -s 1 there if you have trouble with modifier keys) then assign that to whatever key you want. Easy!

KDE users may also want to check out the "KHoKeys" program.

xfce

xfce4 is also easy to add bindings to, as long as you don't need more than its maximum of ten.

Openbox

Put something like this in .config/openbox/rc.xml:
    <keybind key="A-F11">
      <action name="Execute">
        <execute>crikey -s 1 asdf</execute>
      </action>
    </keybind>

For more detail on the key binding syntax, see the Openbox Bindings documentation.

Icewm

Icewm puts key bindings in ~/.icewm/keys, but the procedure is complicated by the problem that icewm apparently can't handle commands with arguments. So for each string you want to bind, make a script, e.g. /home/yourname/bin/saylogname, which looks like this:
#!/bin/sh
crikey -s 1 "mylogname"
The -s 1 is to make sure you have released the modifier key by the time crikey fires. You may need to set it to 2 or some other number.

Make the script executable, of course. Then put the following line in ~/.icewm/keys:

key "Alt+F1" "/home/yourname/bin/saylogname"
Restart icewm and you should be ready to roll.

Fvwm

Fvwm already has this functionality and probably doesn't need crikey! See the FakeKeypress command in the fvwm manual. But if FakeKeypress doesn't work reliably, or if you want to use crikey for some other reason, that's easy too:

PointerKey F9          A M      Exec exec crikey -s 1 "mylogname"

Afterstep

(Instructions courtesy of David North)

First you have to locate the file you're using for your "feel." This is by default in /usr/share/afterstep/feels but if you have any sense, you'll move (not copy) the feel you want to use to your local config directory, which is ~/GNUStep/Library/Afterstep.

You should copy this because (at least in my version) afterstep will show _both_ feels in the Desktop menu (where you select the feel) with the first one being your local copy. Another option is to copy the feel from /usr/share/afterstep/feels and rename it to your own "feel" (such as feel.me).

Edit the file and add something like this:

Key F7       A     N     Exec "(local)" exec crikey "mystring" &
Key F8       A     M     Exec "(local)" exec crikey -s 2 "mystring" &
...in the area where you'll find other commands that start with Key.

The area doesn't matter, but why not stick to the general plan already in place?

Here's what the stuff you see means:
Key F8 is the key you're working with, in this case Function Key 8.
A stuff in the second column means "where". In this case, it means anywhere but in a titlebar. See the notes at the head of the "Key" section for a further explanation.
N means No Modifier key. M means Meta (= Alt), C means Control.
Exec gives a name to the command you want to execute. "(local)" is (I think) a special name that means "Just do it here."
exec the second exec (lower case) calls the actual program. crikey "mystring" & is the crikey program, its argument (There Can Be More Than One) and the & to release control back to the console (or whatever).
-s 2 The -s 2 is needed in the line that uses the modifier key: if it's not there, then when crikey runs, the modifier key will still be down, and all your keys will be interpreted as though you were holding that modifier key down through the whole string. That probably isn't what you intended!

To make your change effective, remember to select this "feel" in the Desktop->Feels menu.

Once you're happy with the setup, remember you have to choose "update all" in the Desktop menu, otherwise your changes will not be remembered after you restart.

Any Window Manager, using Keylaunch

(Instructions courtesy of David North)

These instructions should work with nearly any window manager, using another program called Keylaunch. We've tested it using Gnome and KDE on a couple of different Linux distros plus FreeBSD. I have no affiliation with Keylaunch; it's a program that my helper elves located while trying to figure out how to get crikey working under Gnome.

Basically, get the little program "keylaunch" and configure it. It is also possible to manage this process with xbindkey, but I found that comparitively flaky. You're on your own with that one.

Your first problem is getting the program. On Debian, this is fairly simple: apt-get install keylaunch.

BSD has a port -- just su root cd /usr/ports/x11/ then cd keylaunch and make (and make install if it goes well).

On Redhat/Mandrake/SuSE, you can download source from: http://ftp.debian.org/debian/pool/main/k/keylaunch/keylaunch_1.3.0-6.tar.gz

That's a source tarball that should build just fine anywhere -- I tested it on RedHat9 "as installed."

Otherwise, get it from the Oroborus download page.

Just tar xvzf tarball.gz, cd to the directory, make, and (as root) make install.

However you managed it, at this point you should have the program on your system.

Your next problem is to configure keylaunch. The syntax is fairly simple, and summed up in their example:

# Copy to $HOME/.keylaunchrc
#
# Format:
# key=...KeyName:Command
#
# ... No modifier
# *.. Shift
# .*. Ctrl
# ..* Alt
 
key=..*Return:xterm
key=.**n:netscape
What this overly compressed example says is you need to create a file in your home directory called .keylaunchrc

In that file you put various key=... lines, whatever you want. The first three spaces after key= are either a . or an asterisk that represents the shift, ctrl or alt keys. Then the hard part -- the keyname. Some of them are simply the letter, but others will be such as Menu or F1, F2 etc. The various ways to figure out what key are "beyond the scope of this document" which means the author doesn't exactly know how to do it, usually. That's certainly the case here, but I just use function keys ...

Here's a real example:

	key=...F8:crikey "yourstring"
It's that simple. Note the double quote around the argument to crikey (the string you want to insert). I believe that to be a necessary part of the deal, but experiment at will.

At this point you can test your setup by issuing the command "keylaunch &" at the prompt, then typing whatever hotkey you assigned. If it works, you're in business and your next problem is to get keylaunch to start when you start x.

If you're already loading from .xsession (typical for debian) you may wish to simply add a line containing

	keylaunch
and you're done. This will work well in any system that supports .xinitrc as well. However, RedHat does not.

If you're running gnome on any system, go to Main Menu -> Applications -> Desktop Preferences -> Advanced -> Sessions. Clickon the Startup Programs tab and the Add button. Type in keylaunch and you're good as gold.

However, if you're also running Nautilus, it may intercept the key before keylaunch gets it. If keylaunch prints an error like:

X Error of failed request: BadAccess (attempt to access private resource denied)
Major opcode of failed request: 33 (X_GrabKey)
then nautilus is probably interfering. Killing nautilus fixes the problem; perhaps there's some way to get nautilus to pass the key through (if anyone finds out, please report back so I can update this page).

In KDE, it's a bit trickier. You'll want to know where keylaunch is located, so do a "which keylaunch".

Open the Autostart folder. By default this folder is at $HOME/.kde/share/autostart. Open a Konqueror window and browse to the program you want to add. If you don't know how to do this, Drag and drop the desired program from the Konqueror window on to the autostart folder. When asked, choose Link to create a symbolic link rather than a full copy.

That should do it!

Other Window Managers

If you use crikey with another window manager, please send me the steps and I'll add them here! I'd especially be interested in shorter instructions for modern gnome window managers.
Crikey! Home page
More Software
Shallowsky Home
mail me