LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook
User Name
Password
Linux - Laptop and Netbook Having a problem installing or configuring Linux on your laptop? Need help running Linux on your netbook? This forum is for you. This forum is for any topics relating to Linux and either traditional laptops or netbooks (such as the Asus EEE PC, Everex CloudBook or MSI Wind).

Notices


Reply
  Search this Thread
Old 08-28-2005, 02:42 PM   #1
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,274

Rep: Reputation: 63
volume and access buttons on ze4315


I'm running slackware-current on an HP Pavilion ze4315. Sound works great, but I've never been able to get the hardware volume and mute buttons to work. There is also a row of access buttons across the top for email, internet brower, help, etc. How can I enable these and apply functions to them?
 
Old 08-28-2005, 05:59 PM   #2
flower.Hercules
Member
 
Registered: Aug 2005
Distribution: Gentoo
Posts: 228

Rep: Reputation: 31
I will describe how I went about getting my function keys working (in Openbox on Gentoo).


Grab a piece of paper and a pen to write some stuff down on.

First, I had to get the key codes for each key. Go into the terminal and type `xev` while X.

Push the function key you would like to use and a bunch of output will be displayed, it will look something like this

Code:
KeyPress event, serial 30, synthetic NO, window 0x1600001,
    root 0xb6, subw 0x0, time 26832051, (88,71), root:(999,512),
    state 0x0, keycode 233 (keysym 0xff54, Down), same_screen YES,
    XKeysymToKeycode returns keycode: 104
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 30, synthetic NO, window 0x1600001,
    root 0xb6, subw 0x0, time 26832131, (88,71), root:(999,512),
    state 0x0, keycode 233 (keysym 0xff54, Down), same_screen YES,
    XKeysymToKeycode returns keycode: 104
    XLookupString gives 0 bytes:
for each key press and release (note: make sure not to move your mouse, it will also debug that information). The information you want is in red, above. The critical information that you will probably want to write down is:


Key Function : Key Code : F-key Map

The F-key map will be described later. For now, just get all the keycodes for each key and their respective function.

Then fire up your favorite text editor, hopefully vi :p and make the file ~/.xmodmap, make sure you aren't root'ed, because it will make that file in the root folder and your user won't have it.

Now, this file will map that keycode to an F key of your choice. My keyboard runs up to F12, so I started mapping from F13 and up. The .xmodmap file (period should be leading the filename, that isn't a typo) should look something like this:

Code:
keycode 160     =       F14
keycode 174     =       F15
keycode 176     =       F16
keycode 130     =       F13
keycode 236     =       F17 
keycode 222     =       F18
keycode 223     =       F19
keycode 227     =       F20
keycode 153     =       Next
keycode 162     =       space
keycode 164     =       S s
keycode 144     =       Prior
keycode 233     =       Down 
keycode 234     =       Up
keycode 161     =       F27
keycode 230     =       F28
keycode 122     =       F29
Notice the F keys. Next, space, Prior, Down, and Up are all X functions.

Next = Page Up
Prior = Page Down
Up = Arrow Up
Down = Arrow Down
S s means default to capital S when pushed, lowercase s when holding SHIFT.

Those are all just for controlling Xine and Firefox moving up and down with the keyboard. You don't necessarily need them for what you are doing. The data on the right side of the = will be different for you, as will the keycode numbers. Once you have that set up, you need to tell your window manager what you want each F-key to do (in the case of the Next, S s, Up, Down, etc. they are built in and don't need anything more done with them). Every window manager uses different shortcut keys, I can't describe exactly how yours works, unless you tell me what you are using.

For mine, I have Openbox, so I edited my ~/.config/openbox/rc.xml file, this is what one shortcut looks like:

Code:
<keybind key="F27">
        <action name="execute"><execute>/usr/bin/xcalc</execute></action>
</keybind>
Your configuration file will need edited in another way, that is just an example for the sake of completion.

Now, for those pesky volume keys, I have a couple scripts that will adjust the sound for alsa using amixer. The scripts are below, first you need to put them in your /usr/local/bin or /usr/bin or any other place in your $PATH and do the following:

Code:
chmod +x /usr/bin/<script-name>
where the <script-name> is the name of the script, for example, /usr/bin/mute. All chmod +x does is make the file executable.


Mute Script:
Code:
      #! /bin/bash

      declare -r TEMPVOLFILE="~/volume.tmp"
      declare -r CURRENTVOLUME=$(amixer get Master | grep 'Mono:' | cut -d' ' -f5)
      declare -i NEWVOLUME

      if [ "${CURRENTVOLUME}" == "0" ]
        then
      if [ -f ${TEMPVOLFILE} ]
        then
                NEWVOLUME=$(cat ${TEMPVOLFILE})
      else
                NEWVOLUME=50
       fi
       amixer set Master ${NEWVOLUME}
      else
       echo ${CURRENTVOLUME} > ${TEMPVOLFILE}
       amixer set Master 0
      fi
      exit 0
That makes the file volume.tmp in your home directory and stores the current volume level of the Master line in it for when you want to unmute (it doesn't work like Windows, there is no real mute/unmute for Linux sound). It then sets the volume to 0, when you press the mute key again, it grabs the number from the file and sets it, if the file is gone, it sets it to a default of 50, or 50%.


Volume Up:
Code:
      #! /bin/bash

      amixer set Master 1+
      exit 0
Adds 1 to the current volume.


Volume Down:
Code:
      #! /bin/bash

      amixer set Master 1-
      exit 0
That is all it takes. The rest of the keys you will just bind like I showed you above to your current window manager according to their path. The final step is to run `xmodmap ~./xmodmap` and preferably put that in your .xinitrc to start up when your window manager starts.

Good luck, HTH.

Last edited by flower.Hercules; 08-28-2005 at 06:01 PM.
 
Old 08-28-2005, 06:09 PM   #3
Jaxån
Member
 
Registered: Apr 2005
Location: Sweden
Distribution: Debian
Posts: 142

Rep: Reputation: 15
If you use KDE or GNOME, they have programs to associate some programs to different funktions keys, like those. Otherwise there is a daemon that you kan program, but I forgot the name Sorry. GNOME's key programmer is based on that deamon, anyway. Someone else?

(Mor about your environment like window manager etc. would help)
 
Old 08-28-2005, 06:22 PM   #4
flower.Hercules
Member
 
Registered: Aug 2005
Distribution: Gentoo
Posts: 228

Rep: Reputation: 31
In KDE you can map the F-keys with the Configure Shortcut window.

The reason I described this is because it will work for `all` window managers and it is always better to actually know how everything is working, instead of having a program break down on you and have to scramble to get it to work again. Also, I tried a few program's that supposedly did all this for you, one was for KDE, and it didn't work at all.

KDE = KHotKeys
Gnome = gnome-keyboard-bindings

LinEAK could be another easy solution.
 
Old 08-28-2005, 06:51 PM   #5
Jaxån
Member
 
Registered: Apr 2005
Location: Sweden
Distribution: Debian
Posts: 142

Rep: Reputation: 15
Quote:
Originally posted by flower.Hercules
In KDE you can map the F-keys with the Configure Shortcut window.

KDE = KHotKeys
Gnome = gnome-keyboard-bindings

LinEAK could be another easy solution.
Gnome kyeboards binding is based on LinEAK, thanks.
Here is another link that could be usefull (Google is your friend).
http://gentoo-wiki.com/HOWTO_Use_Multimedia_Keys
 
Old 08-29-2005, 06:51 AM   #6
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,274

Original Poster
Rep: Reputation: 63
Thank you for the quick posts. I should've mentioned more about the environment before, but I was rushed. I use both KDE and Fluxbox. To clarify, I'm not attempting to map F-keys. I can control volume fine from KMixer ar amixer. This is an HP laptop with the volume keys on the left side next to the headphone connector. Above the F-keys is a row of extra buttons with pictures representing internet, email, help, etc. Here's a pic:

http://allclassifieds.com.au/img-320...bba02036bb.jpg

It's a bit small but I think you can see the small white buttons on the side (volume) and the 5 silver buttons closest to the screen.

flower.Hercules's idea sound like a possibility. I'll give that a try.
 
Old 08-29-2005, 07:04 AM   #7
flower.Hercules
Member
 
Registered: Aug 2005
Distribution: Gentoo
Posts: 228

Rep: Reputation: 31
That Gentoo tutorial has help on setting those customized keys up too, as does the config documentation. Shouldn't be too hard Best of luck.
 
Old 08-29-2005, 01:00 PM   #8
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,274

Original Poster
Rep: Reputation: 63
flower.Hercules, so far your guide has been what I need. However, the mute button and a couple of the quickaccess buttons don't return a keycode when I press them. That's ok - the ones I would want to use do. I modified my Xmodmap file to map the codes to F-numbers. Since I use Fluxbox primarily now, I'll find out which file to edit there to set the actions. Where can I find a list of those X functions, like next, prior, etc. ?

Thanks!
 
Old 08-29-2005, 04:14 PM   #9
flower.Hercules
Member
 
Registered: Aug 2005
Distribution: Gentoo
Posts: 228

Rep: Reputation: 31
I can't remember the exact filename, it is an x file, but it was just a program that made a window with the keyboard in it and you pressed the key and it told you what the key function was. xev does the same thing.

Code:
KeyRelease event, serial 30, synthetic NO, window 0x1800001,
    root 0xb6, subw 0x0, time 971837, (-70,355), root:(480,447),
    state 0x0, keycode 99 (keysym 0xff55, Prior), same_screen YES,
    XLookupString gives 0 bytes:
 
Old 08-31-2005, 11:46 AM   #10
rataime
LQ Newbie
 
Registered: Aug 2005
Posts: 2

Rep: Reputation: 0
"acme" is another simple deamon to activate the multimedia keys.
However, it won't work with buttons that don't return anything...
 
Old 08-31-2005, 12:17 PM   #11
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,274

Original Poster
Rep: Reputation: 63
The xev procedure so far has worked nicely. The volume buttons work now and I've mapped the browser and email buttons to firefox and thunderbird.

I just got a new HP wireless keyboard for my desktop computer. Using the same procedure I got codes for the browser and multimedia keys. Only one button didn't respond and a few codes were already linked to letters. My only question now is: How do I activate the browser keys on this one? Do I need to do something with the keyboard layout?

Thanks for everything so far.
 
Old 08-31-2005, 03:48 PM   #12
flower.Hercules
Member
 
Registered: Aug 2005
Distribution: Gentoo
Posts: 228

Rep: Reputation: 31
You can try mapping scancodes to keycode using the `showkey` command. Check out man showkey for some very useful information (it really is helpful ). As for the ones that were mapped to letters, xmodmap in your home dir should overwrite the default map in which they are already letters.
 
Old 08-31-2005, 04:53 PM   #13
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,274

Original Poster
Rep: Reputation: 63
Thanks, I'll check that out later. I've read some stuff about the XF86 symkeys, like XF86Back and XF86HomePage. Would those work?
 
Old 08-31-2005, 08:09 PM   #14
flower.Hercules
Member
 
Registered: Aug 2005
Distribution: Gentoo
Posts: 228

Rep: Reputation: 31
I didn't have any luck with the XFree86 functions on Xorg, they might work, I'm not positive.
 
Old 09-01-2005, 03:04 PM   #15
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,274

Original Poster
Rep: Reputation: 63
From what I've been reading on the subject, the XF syms only apply to the keyboard layout loaded with xorg.conf. I think I found what I need - a list of the keyboard shortcuts for Firefox. Since it's the only browser I use other than Konqueror I'll see if I can use KHotKeys to make them all the same between the two and map the key combinations to my buttons. For Fluxbox I should be able to set the combinations in the keys file.

Thanks for all the help!
 
  


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
mute/volume buttons to work? microsoft/linux Linux - Laptop and Netbook 7 08-20-2005 02:35 PM
volume buttons on my laptop emg SUSE / openSUSE 1 06-24-2005 10:34 PM
Volume Buttons on an HP-ze4805US efanning Linux - Laptop and Netbook 3 09-08-2004 01:51 PM
external volume buttons nef Linux - Laptop and Netbook 14 10-14-2003 01:35 PM
volume buttons on Inspiron 8200 disciple061 Linux - Laptop and Netbook 1 07-22-2003 05:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook

All times are GMT -5. The time now is 10:39 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