Wandering Thoughts archives

2016-08-01

My new key binding hack for xcape and dmenu

When I started using dmenu, I set up my window manager to start it when I hit F5. F5 was a conveniently reachable key on the keyboard that I was using at the time and I was already binding F2 and F3 (for 'lower window' and 'raise window'). This worked pretty well, but there was a slight inconvenience in that various programs use F5 for their 'refresh this' operation and my window manager key binding thus stole F5 from them. Web browsers have standardized on this, but more relevant for me is that kdiff3 also uses it to refresh the diff it displays.

(For various reasons kdiff3 is my current visual diff program. There's also meld, but for some reason I never took to it the way I've wound up with kdiff3. There are other alternatives that I know even less about.)

Later on I got a new keyboard that made F5 less conveniently accessible. Luckily, shortly afterwards evaryont turned me on to xcape and I promptly put it to work to make tapping the CapsLock key into an alias for F5, so that I could call up dmenu using a really convenient key. Fast forward to today and the obvious has happened; I don't use the actual F5 key to call up dmenu any more, I do it entirely by tapping CapsLock, because that's much nicer.

Xcape doesn't directly invoke programs; instead it turns tapping a key (here, the CapsLock) into the press of some other key (here, F5). It's up to you to make the other key do something interesting. Recently, the obvious struck me. If all I'm using the F5 key binding for is as a hook for xcape, I don't actually have to bind F5 in fvwm; I can bind any arbitrary key and then have xcape generate that key. In particular, I can bind a key that I'm not using and thereby free up F5 so regular programs can use it.

If I was clever and energetic, I would trawl through the X key database to find some key that X knows about but that doesn't actually exist on my keyboard. I'm not that energetic right now, so I went for a simpler hack; instead of binding plain F5, I've now bound Shift Control Alt F5. This theoretically could collide with what some program wants to do with F5, but it's extremely unlikely and it frees up plain F5.

(It also has the potentially useful side effect that I can still call up dmenu if the xcape process is dead. If I bound dmenu to a completely inaccessible key, that wouldn't be possible. Of course the real answer is that if xcape dies I'm just going to restart it, and if this isn't possible for some reason I'm going to dynamically rebind dmenu to an accessible key by using fvwm's console.)

sysadmin/XcapeFvwmKeybindingHack written at 23:00:41; Add Comment


Page tools: See As Normal.
Search:
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.