WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Programming function keys  (Read 4840 times)

Offline khagberg

  • Newbie
  • *
  • Posts: 6
Programming function keys
« 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

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Programming function keys
« Reply #1 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.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: Programming function keys
« Reply #2 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.

Offline khagberg

  • Newbie
  • *
  • Posts: 6
Re: Programming function keys
« Reply #3 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

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: Programming function keys
« Reply #4 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, near the bottom.

HTH
« Last Edit: December 15, 2010, 08:10:27 PM by dentonlt »

Offline khagberg

  • Newbie
  • *
  • Posts: 6
Re: Programming function keys
« Reply #5 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

Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: Programming function keys
« Reply #6 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...
« Last Edit: December 16, 2010, 05:43:32 PM by dentonlt »

Offline khagberg

  • Newbie
  • *
  • Posts: 6
Re: Programming function keys
« Reply #7 on: December 16, 2010, 08:34:01 PM »
Got it. Thanks

Works like a champ

need to use /dev/input/event4


Offline dentonlt

  • Sr. Member
  • ****
  • Posts: 318
    • the trombone analog
Re: Programming function keys
« Reply #8 on: December 17, 2010, 01:08:52 AM »
Great to hear :)

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: Programming function keys
« Reply #9 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.
The only barriers that can stop you are the ones you create yourself.