Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Multimedia keys in Openbox
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
monotux
l33t
l33t


Joined: 09 Sep 2003
Posts: 751
Location: Stockholm, Sweden

PostPosted: Sat Jan 01, 2005 10:48 pm    Post subject: Multimedia keys in Openbox Reply with quote

Hello everyone! :)
Ever wanted to use custom keybindings for the multimedia buttons on your keyboard in openbox, without using gnome or lineak?
I spent some time searching for a solution for this, and found bits of information along the way, and I thought that I should share my solution with you all.

First of all - get yourself a multimedia keyboard! ;)
Start X and a terminal, launch the program xev.
Here's a sample from my output:
Code:
KeyRelease event, serial 30, synthetic NO, window 0x1200001,
    root 0xaf, subw 0x0, time 1022523, (72,79), root:(73,461),
    state 0x0, keycode 237 (keysym 0xffca, F13), same_screen YES,
    XLookupString gives 0 bytes:

The output is quite messy, but look for the word "keycode".
As in my example, my keycode was 237.
Write your keycodes down somewhere, because we're gonna use them later.

Fire up your favourite editor, and open ~/.Xmodmap (yes, you can also use /etc/X11/Xmodmap, but that requires root privileges).
With Xmodmap, you can name your keycodes to something openbox can understand - it's not very hard, here's the syntax:
Code:
keycode {your keycode} = name

I recommend that you name your multimedia keys F13, F14, F15 etc, (KISS - keep it simple, stupid!).
Here's my Xmodmap:
Code:
keycode 237 = F13
keycode 162 = F14
keycode 160 = F15
keycode 230 = F16
keycode 236 = F17
keycode 178 = F18


The final part - configuring Openbox.
Not very hard, either :D
Open ~/.config/openbox/rc.xml with your favourite editor, and look for the keyboard section (between <keyboard> and </keyboard>).
The syntax, if you want to execute a program when the button is pushed:
Code:
<keybind key="F13">
<action name="execute><execute>yourapp</execute></action>
</keybind>


Tips and tricks
I couldn't make this work, until I changed my xorg.conf and appended this to the keyboard section:
Code:
Option "XkbVariant"  "nodeadkeys"

I asume that it has something to do with my swedish layout, but it might work if you have a us keyboard.
_________________
Computer science is no more about computers than astronomy is about telescopes.
Back to top
View user's profile Send private message
bladdo
Guru
Guru


Joined: 19 Jul 2004
Posts: 334
Location: NJ

PostPosted: Sun Jan 02, 2005 12:49 am    Post subject: Reply with quote

Ok I use OB and Ive known this for a while but I want to know how I can take advantage of the sound up and down buttons on my keybaord.
_________________
Bladdo formerly >Milo<
bladdo.net - scripting and design
Creator of AIM Bot: Tiny Tiny Bot - the bot that learns
distro: gentoo | window manager: pekwm
Back to top
View user's profile Send private message
monotux
l33t
l33t


Joined: 09 Sep 2003
Posts: 751
Location: Stockholm, Sweden

PostPosted: Sun Jan 02, 2005 1:16 am    Post subject: Reply with quote

MiMi wrote:
Ok I use OB and Ive known this for a while but I want to know how I can take advantage of the sound up and down buttons on my keybaord.

there is a program in the alsa suit that gives you the ability to set your volume using the command line (like "program volume +5") - I just can't remember it's name.
_________________
Computer science is no more about computers than astronomy is about telescopes.
Back to top
View user's profile Send private message
finr
Tux's lil' helper
Tux's lil' helper


Joined: 24 Feb 2004
Posts: 126

PostPosted: Sun Jan 02, 2005 11:55 am    Post subject: Reply with quote

aumix should do the trick :)...

It's something like aumux -v +5 or aumix -v -5, iirc.
Back to top
View user's profile Send private message
bladdo
Guru
Guru


Joined: 19 Jul 2004
Posts: 334
Location: NJ

PostPosted: Sun Jan 02, 2005 2:38 pm    Post subject: Reply with quote

Thanks
_________________
Bladdo formerly >Milo<
bladdo.net - scripting and design
Creator of AIM Bot: Tiny Tiny Bot - the bot that learns
distro: gentoo | window manager: pekwm
Back to top
View user's profile Send private message
Mikachu
n00b
n00b


Joined: 03 Jan 2005
Posts: 2

PostPosted: Mon Jan 03, 2005 10:41 pm    Post subject: Reply with quote

You can also use "0xXX" where XX is the hexadecimal representation of the keycode so you don't have to set up keysyms
Back to top
View user's profile Send private message
monotux
l33t
l33t


Joined: 09 Sep 2003
Posts: 751
Location: Stockholm, Sweden

PostPosted: Sat Jan 15, 2005 10:36 pm    Post subject: Reply with quote

Mikachu wrote:
You can also use "0xXX" where XX is the hexadecimal representation of the keycode so you don't have to set up keysyms


And how do you find out the hexadecimal adress then? :)
_________________
Computer science is no more about computers than astronomy is about telescopes.
Back to top
View user's profile Send private message
phate
Apprentice
Apprentice


Joined: 22 Mar 2004
Posts: 298
Location: Aachen, Germany

PostPosted: Sat Feb 26, 2005 7:38 pm    Post subject: Reply with quote

finr wrote:
aumix should do the trick :)...

It's something like aumux -v +5 or aumix -v -5, iirc.


hmm i dont have something called "aumix"
which package is it in?
Back to top
View user's profile Send private message
monotux
l33t
l33t


Joined: 09 Sep 2003
Posts: 751
Location: Stockholm, Sweden

PostPosted: Sat Feb 26, 2005 11:21 pm    Post subject: Reply with quote

phate wrote:
finr wrote:
aumix should do the trick :)...

It's something like aumux -v +5 or aumix -v -5, iirc.


hmm i dont have something called "aumix"
which package is it in?


http://gentoo-portage.com/media-sound/aumix
_________________
Computer science is no more about computers than astronomy is about telescopes.
Back to top
View user's profile Send private message
Chaosite
Guru
Guru


Joined: 13 Dec 2003
Posts: 540
Location: Right over here.

PostPosted: Wed Mar 16, 2005 10:58 am    Post subject: Reply with quote

furiorc wrote:
Mikachu wrote:
You can also use "0xXX" where XX is the hexadecimal representation of the keycode so you don't have to set up keysyms


And how do you find out the hexadecimal adress then? :)


Ummm... You convert the decimal keycode to hex? I guess you would use a good calculator.
Back to top
View user's profile Send private message
monotux
l33t
l33t


Joined: 09 Sep 2003
Posts: 751
Location: Stockholm, Sweden

PostPosted: Thu Mar 17, 2005 12:52 am    Post subject: Reply with quote

Chaosite wrote:
furiorc wrote:
Mikachu wrote:
You can also use "0xXX" where XX is the hexadecimal representation of the keycode so you don't have to set up keysyms


And how do you find out the hexadecimal adress then? :)


Ummm... You convert the decimal keycode to hex? I guess you would use a good calculator.


I can do it with a paper and a pencil.
But I was wondering how you obtained the hexedecimal number...I think :)
_________________
Computer science is no more about computers than astronomy is about telescopes.
Back to top
View user's profile Send private message
Chaosite
Guru
Guru


Joined: 13 Dec 2003
Posts: 540
Location: Right over here.

PostPosted: Sun Mar 20, 2005 4:54 pm    Post subject: Reply with quote

Its the hexadecimal representation of the decimal keycode...

At least, thats what it looks like.
Back to top
View user's profile Send private message
Chaosite
Guru
Guru


Joined: 13 Dec 2003
Posts: 540
Location: Right over here.

PostPosted: Sun Mar 20, 2005 5:07 pm    Post subject: Reply with quote

Here, I just tried it, and it does work.

So:

Lets say the keycode to my volume up key is 176. So I do:
Code:
chaosite@Aurora ~ $ printf %x 176
b0


then, in the correct place in my rc.xml, I do:
Code:
<keybind key="0xB0">
 <action name="Execute"><execute>mpc volume +1</execute></action>
</keybind>


Pretty simple, yes?
Back to top
View user's profile Send private message
rosschilen
n00b
n00b


Joined: 04 Sep 2004
Posts: 15

PostPosted: Tue Mar 22, 2005 9:13 pm    Post subject: Reply with quote

how do i set a key to mute/unmute with aumix? I know i could set the sound level to 0 when a key is pressed but I would like to have 1 key that mutes the sound; then when pressed again restores the sound to the orignial level.
Back to top
View user's profile Send private message
redss
n00b
n00b


Joined: 07 Jan 2005
Posts: 9

PostPosted: Sun Apr 10, 2005 6:49 pm    Post subject: Reply with quote

I don't think aumix has a command line option to mute/unmute, so I wrote the following script as a workaround. I assign it to a multimedia key via kde hotkeys, and it stores the volume level (in a file called 'muted') before muting, so that it can restore to the same volume when unmuting.
Code:

#/bin/sh
cd
if [ -f muted ];
then
  aumix -v `cat muted`
  rm -f muted
else
  aumix -q | grep vol | cut -f3 -d' ' > muted
  aumix -v 0
fi
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum