LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-03-2005, 09:36 AM   #1
JoannesX
Member
 
Registered: Dec 2004
Location: Brazil
Distribution: Slackware
Posts: 99

Rep: Reputation: 15
Assigning functions to inactive keys...


HI fellas...

I'd like to know how i can assign functions or at least make some keys (such as the multimedia keys) work... It'd be great if I could open Kaffeine Media Pĺayer just pressing the "Media" key in the keyboard.. But It'd be even better if the "Prev Track" and "+ - volume" worked as well..

How do I make them work and assign functions to them..???

Thanks.. I'm using Slackware 10.1, KDE 3.3...
 
Old 05-03-2005, 09:42 AM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
I have them working on my keyboard, which I just recently got.

Well, I have all but the Forward and Back arrows (for the browser), but I'm working on those.

Anyway, Look into a program called "hotkeys". It's really straightforward to get set up.
 
Old 05-03-2005, 09:59 AM   #3
oneandoneis2
Senior Member
 
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460

Rep: Reputation: 48
All you need to know are the commands "xev" and "xmodmap". xev tells you what the keycodes are, xmodmap tells your computer what to do when it receives a particular keycode.

I have forward & back buttons for my browser, along with volume & media player controls. It's dead easy
 
Old 05-03-2005, 11:04 AM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
How did you set up the forward and back buttons?

And I like hotkeys because it will let it run arbitrary applications regardless of even the desktop environment/wm.
 
Old 05-03-2005, 11:37 AM   #5
JoannesX
Member
 
Registered: Dec 2004
Location: Brazil
Distribution: Slackware
Posts: 99

Original Poster
Rep: Reputation: 15
I knew about xev and xmodmap.. but the fact is that nothing happens when I press "media" keys..
they're noit being even recognized I think...

well.. i've already checked hotkeys..
 
Old 05-03-2005, 11:40 AM   #6
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
xev doesn't show anything when pressing a media key?

is this keyboard USB or PS/2?
 
Old 05-03-2005, 11:48 AM   #7
JoannesX
Member
 
Registered: Dec 2004
Location: Brazil
Distribution: Slackware
Posts: 99

Original Poster
Rep: Reputation: 15
no it shows.. yea right it shows.. see what happens:
===============================================
KeyPress event, serial 30, synthetic NO, window 0x2800001,
root 0xd6, subw 0x0, time 146506665, (727,957), root731,987),
state 0x10, keycode 237 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False

KeyRelease event, serial 30, synthetic NO, window 0x2800001,
root 0xd6, subw 0x0, time 146506785, (727,957), root731,987),
state 0x10, keycode 237 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
===============================================

how can I make it .. for example open JuK.. (my media player)..
i just wanted to put it in the "keyboard shortcuts" .. but when I press it.. nothing appears..
 
Old 05-03-2005, 11:54 AM   #8
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Then you probably need to map the key to a X keycode first, using xmodmap.
 
Old 05-03-2005, 12:19 PM   #9
JoannesX
Member
 
Registered: Dec 2004
Location: Brazil
Distribution: Slackware
Posts: 99

Original Poster
Rep: Reputation: 15
can u tell me a syntax.. i didnt understand the one i got from the help..
i type "xmodmap" and???
 
Old 05-03-2005, 01:29 PM   #10
oneandoneis2
Senior Member
 
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460

Rep: Reputation: 48
Okay, here's what I have for my hotkeys:

An Xmodmap file with the contents
Code:
keycode 115 = F13 
keycode 116 = F14 
keycode 117 = F15 
keycode 234 = F16 
keycode 233 = F17 
keycode 231 = F18 
keycode 122 = F19 
keycode 230 = F20 
keycode 130 = F21 
keycode 160 = F22 
keycode 174 = F23
keycode 176 = F24
keycode 162 = F25
keycode 164 = F26
keycode 144 = F27
keycode 153 = F28
This is executed by Xorg on startup - see your Xsession file. The keycodes were obtained by xev. In your example, you would use keycode 237 = F13 (or whatever key)

This gives me a whole load of new function keys - F13 to F28.

Then in my .fvwm2rc (FVWM is my windows manager) I have the following:
Code:
Key F13         A       A       Popup "Utilities"
Key F14         A       A       Menu "Window Ops" Nop
Key F15         A       A       WindowList
Key F16         A       A       Exec mozillaback
Key F17         A       A       Exec mozillaforward
Key F18         A       A       Exec mozillarefresh
Key F19         A       A       Exec mozillasearch 
Key F20         A       A       Exec mozillafaves  
Key F21         A       A       Exec mozillahome   
Key F22         A       A       Exec xmmsmute      
Key F23         A       A       Exec xmmsvoldown   
Key F24         A       A       Exec xmmsvolup     
Key F25         A       A       Exec xmmsplay      
Key F26         A       A       Exec xmmsstop      
Key F27         A       A       Exec xmmsprev      
Key F28         A       A       Exec xmmsnext
The things it executes are simple shell scripts. mozillaback, for instance, executes:
Code:
firefox -remote "openURL(javascript:history.go(-1);)"

Last edited by oneandoneis2; 05-03-2005 at 01:31 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting php5 socket functions to php3 socket functions mrobertson Programming 0 06-23-2005 09:11 AM
Assigning keyboard shortcuts to keyboard keys the who Linux - Hardware 3 02-20-2004 09:36 PM
changing keyboard keys functions grizzly Slackware 2 01-10-2004 09:05 PM
Configuring SSH to accept only keys (already have keys) fr0st Linux - Security 3 11-04-2003 03:31 AM
pointers to functions/member functions champ Programming 2 03-28-2003 06:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration