3

I'd like to show the state of xkb on status bar of (preferably any) window manager. State should include LED-indicators (both physical and virtual), modifier state, and both keycode and keysym each time some key is pressed.

I've looked at xkbvleds with an intention to retrieve LED-state, but as far as I can see, it does not return any parsable information; just a new window with pre-defined appearance. I don't see a way to use it in the way I want to.

I've looked at xev with an intention to retrieve the keycodes and keysyms of pressed keys, but it works only if focus is on specified window. I'd like to monitor keypresses globally, letting them through unmodified.

Finally, I've looked at xinput, and it seems to me that I might be able to retrieve keypresses with that. It just looks a rather painful way to achieve what I want (if it would even work).

This does not seem that exotic need in my eyes, which makes me think that I'm looking it in a wrong way, and/or missing something more or less obvious.

Personally I'm looking for window manager -independent solutions here.

2 Answers2

0

Maybe xxkb or xkbind would be useful.

  • Thank you for your answer!

    It seems to me that they both are keyboard layout switchers and/or indicators, and don't do any keyboard event monitoring. I'd like to see e.g. text "Caps" if I have caps lock on, or "Control bracketleft" if I press C-[. And that should be shown on status bar.

    – montiainen Sep 20 '15 at 16:35
0

You can get the keyboard up/down events and their keycode with cnee. Eg, for me:

cnee --record --keyboard | awk -F, '$1==7{print $2 " " $6}'

when I press then release the left shift key (keycode 50) outputs:

2 50
3 50

xmodmap -pke lists the keysyms for the keycodes. Your X11 server must have the RECORD extension:

xdpyinfo | grep RECORD
meuh
  • 51,383
  • Thanks for your answer! I didn't know that program, and indeed it could be useful for some other task, but I'm still not quite satisfied with this for the task I'm talking about. – montiainen Sep 23 '15 at 14:54