You are not logged in.

#1 2008-02-22 12:51:50

HyperBaton
Member
From: Belgium
Registered: 2008-01-18
Posts: 207

Binding keys to commands in console (NOT in X server)

Hi,

I've found tons of tutorials on how to bind keys to keysyms/commands in all the different window managers (and using it as well in XFCE), but I want to bind certain keys to certain commands in the console. And I can't seem to find any info on how to do that... I want to setup some shortcut keys for when I'm working in a real console (Ctrl-ALt-F1...). Xmodmaps do not work anymore once you enter such a console.

Does anyone have some info on how I can accomplish this?

Offline

#2 2008-02-22 13:11:35

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: Binding keys to commands in console (NOT in X server)

Not sure this is the answer, but you could use .inputrc.
For example you can set it up to use combination of keys to be read in certain ways. In mine I have:

"SV" = "sudo vim "

so that whenever I type SV, "sudo vim" comes up. Now I don't know how flexible this is, but it might be a starting point...


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#3 2008-02-22 14:09:41

HyperBaton
Member
From: Belgium
Registered: 2008-01-18
Posts: 207

Re: Binding keys to commands in console (NOT in X server)

That is helpful yes... But how would you go about assigning for example a media button? Just ike you would assign the play button to XF86AudioPlay in Xmodmap, but instead I want to assign a fixed command to it. I know the kernel keycodes of the buttons using 'showkey'...

Offline

#4 2008-02-22 21:04:04

Stoffi
Member
Registered: 2007-03-15
Posts: 107

Re: Binding keys to commands in console (NOT in X server)

I am wondering the same.
it would be nice to have my volume keys work without starting X.

Offline

#5 2008-02-22 22:10:20

smoon
Member
Registered: 2005-08-22
Posts: 468
Website

Re: Binding keys to commands in console (NOT in X server)

Sounds like what you want is actkbd. Works pretty well in the console, in X and even from within fullscreen OpenGL games. Unfortunately it sometimes fails to detect my keyboard correctly sad

Offline

#6 2008-02-23 03:54:45

peets
Member
From: Montreal
Registered: 2007-01-11
Posts: 936
Website

Re: Binding keys to commands in console (NOT in X server)

actkbd looks interesting, but it won't react at all to my input.

$ sudo actkbd --showexec --showkey -l -c /etc/actkbd.conf -v9 -D
Event interface present (handler 2)
Detected a usable keyboard device (event3)
Using configuration file /etc/actkbd.conf
Config: 232 -:- key -:-  -:- mpc play

then whatever I press, nothing happens.

Offline

#7 2008-02-23 09:09:46

smoon
Member
Registered: 2005-08-22
Posts: 468
Website

Re: Binding keys to commands in console (NOT in X server)

peets wrote:

actkbd looks interesting, but it won't react at all to my input.

$ sudo actkbd --showexec --showkey -l -c /etc/actkbd.conf -v9 -D
Event interface present (handler 2)
Detected a usable keyboard device (event3)
Using configuration file /etc/actkbd.conf
Config: 232 -:- key -:-  -:- mpc play

then whatever I press, nothing happens.

It probably did not detect your keyboard properly then. Look at your `dmesg' output and figure out the input device assigned to your keyboard. Then go to the appropriate sysfs path to see which event interface it has. If it is for example event4, you can try

actkbd -d /dev/input/event4

Offline

#8 2008-02-23 13:40:11

HyperBaton
Member
From: Belgium
Registered: 2008-01-18
Posts: 207

Re: Binding keys to commands in console (NOT in X server)

Awesome, this worked like a charm! Thanks!

Offline

#9 2008-02-23 23:33:20

peets
Member
From: Montreal
Registered: 2007-01-11
Posts: 936
Website

Re: Binding keys to commands in console (NOT in X server)

O.K. I got actkbd to use the right device.

However, not matter what I try, I can't get it to do what I want without either 1. passing the keypress on (e.g. setting a command to alt+a will also type 'a' when I press alt+a) or 2. grabbing the keyboard for an undetermined amount of time.

I'm not very good at this.

Offline

#10 2008-02-25 00:34:19

DonVla
Member
From: Bonn, Germany
Registered: 2007-06-07
Posts: 997

Re: Binding keys to commands in console (NOT in X server)

screen is the key.
i use screen shortcuts for all console apps i use, like mutt, htop, wyrd, different logs, slurm, root login. when you get use to screen, it's really handy. though it doesn't handle multimedia keys.
e.g., add smth like :  "bind x screen -t 'mutt'        2 mutt" to your .screenrc, then hitting "C-a x" opens mutt in a new screen tab.
vlad

Offline

#11 2008-03-23 22:11:28

Stoffi
Member
Registered: 2007-03-15
Posts: 107

Re: Binding keys to commands in console (NOT in X server)

here is my current config, maybe that can help you?
it doesn't work to keep the buttons pressed, I haven't
had a look into that yet, but it should be fairly simple. smile

# actkbd configuration file
113:key:exec:amixer -q set Master toggle
114:key:exec:amixer -q set Master 2- unmute
115:key:exec:amixer -q set Master 2+ unmute

Offline

Board footer

Powered by FluxBB