Tiny Core Linux

Tiny Core Base => TCB Q&A Forum => Topic started by: khagberg on December 13, 2010, 10:53:19 AM

Title: Programming function keys
Post by: khagberg on December 13, 2010, 10:53:19 AM
Is there a way to program a function key within Tinycore to have it execute a program. If I press F1 run program /usr/bin/abc F2 run /usr/bin/def

Thanks
Title: Re: Programming function keys
Post by: tinypoodle on December 13, 2010, 11:25:53 AM
A possible approach would be to do so with any window manager which allows to define keybindings. Not sure if that serves your purpose.
Title: Re: Programming function keys
Post by: dentonlt on December 15, 2010, 04:52:35 AM
I use actkbd to link function keys to suspend/mute/vol/etc. It's in the repository, courtesy of curaga.

I don't think actkbd can conditionally grab keys, however - so it's always use that key press for your program, or not.

Or ... get the flwm code and edit.
Title: Re: Programming function keys
Post by: khagberg on December 15, 2010, 03:55:12 PM
I was looking at that and am having trouble figuring out how to trap a function key. Seems to be able to grab special function keys but have not been able to trap the F1 key
Title: Re: Programming function keys
Post by: dentonlt on December 15, 2010, 07:36:25 PM
Hmm. You should be able to trap pretty much anything, given the right keycodes/scancodes.

Get showkey from the repository - it will show you the key codes you need. Install the extension, exit to prompt, get your key codes. You may have to run it sudo.

EDIT: My config file appears at http://www.dentonlt.com/node/225 (http://www.dentonlt.com/node/225), near the bottom.

HTH
Title: Re: Programming function keys
Post by: khagberg on December 15, 2010, 08:45:15 PM
I grabbed showkey and it says F1 is keycode 59.

I created a config file with

59 :key :grabbed,ungrab :aterm

then loaded up actkbd but nogo on getting aterm to launch on pressing F1

Any hint would be great.

Thanks
Title: Re: Programming function keys
Post by: dentonlt on December 16, 2010, 05:37:19 PM
Quote
I created a config file with

59 :key :grabbed,ungrab :aterm

then loaded up actkbd but nogo on getting aterm to launch on pressing F1

Regarding your configuration, that should work. I'd do this, which launches on release instead of press:

Code: [Select]
59:key:noexec:
59:rep:noexec:
59:rel:exec:aterm

More likely, do you have your /dev/input/eventX items set correctly? I didn't have a way of finding that, so ... I used an actkbd.conf that would respond to any key press (quick correction made - use "not"):

Code: [Select]
:key:not,exec:echo "press!"
And then ran actkbd individually per /dev/input/event entry:

Code: [Select]
actkbd -c /my path to/actkbd.conf -d /dev/input/event1
Or something like that. Be careful, of course, or actkbd may grab your keyboard and not give it back...
Title: Re: Programming function keys
Post by: khagberg on December 16, 2010, 08:34:01 PM
Got it. Thanks

Works like a champ

need to use /dev/input/event4

Title: Re: Programming function keys
Post by: dentonlt on December 17, 2010, 01:08:52 AM
Great to hear :)
Title: Re: Programming function keys
Post by: curaga on December 17, 2010, 04:14:58 AM
cd /sys/class/input

for i in input*/name; do echo $i; cat $i; done

input0 is event0 in /dev/input.