User avatar
solar3000
Posts: 1059
Joined: Sat May 18, 2013 12:14 am

Keyboard volume controls

Mon Aug 26, 2013 7:20 pm

How do you get the keyboard vol + - mute to work?

I'm running raspbian.
Antikythera

User avatar
pluggy
Posts: 3635
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
Contact: Website

Re: Keyboard volume controls

Tue Aug 27, 2013 12:51 pm

Since volume/mute controls aren't standard on a keyboard, it would probably need a Pi specific driver for the keyboard in question.
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......

mnoit
Posts: 8
Joined: Sat Aug 24, 2013 10:18 am
Location: Lille France

Re: Keyboard volume controls

Wed Aug 28, 2013 2:50 pm

triggerhappy should be installed by default. If not:

Code: Select all

sudo apt-get install triggerhappy
Then you have to configure it, and that is done by hand.

Code: Select all

less /usr/share/doc/triggerhappy/README
man thd
5 pm; appointement soon; will watch the thread for further help if needed;)

Code: Select all

thd --dump /dev/input/*
and hit the key you want.

User avatar
solar3000
Posts: 1059
Joined: Sat May 18, 2013 12:14 am

Re: Keyboard volume controls

Sat Aug 31, 2013 3:27 am

I don't see where you would put the .conf file.
I would guess somewhere in /etc
Antikythera

mnoit
Posts: 8
Joined: Sat Aug 24, 2013 10:18 am
Location: Lille France

Re: Keyboard volume controls

Sat Aug 31, 2013 11:49 am

The global config file is /etc/default/triggerhappy. you should'nt need to edit that.
The mapings for your specific keys go to /etc/triggerhappy/triggers.d/
From the man page:
Any number of event handlers can be placed in the configuration file:

Code: Select all

           # /etc/triggerhappy/triggers.d/suspend.conf
           #
           # Suspend the system
           KEY_SLEEP                   1       /usr/sbin/hibernate-ram
           KEY_SLEEP+KEY_LEFTSHIFT     1       /usr/sbin/hibernate-disk
           
           # /etc/triggerhappy/triggers.d/audio.conf
           # Change mixer volume when pressing the appropriate keys (or holding them)
           KEY_VOLUMEUP    1      /usr/bin/amixer set Master 5%+
           KEY_VOLUMEUP    2      /usr/bin/amixer set Master 5%+
           KEY_VOLUMEDOWN  1      /usr/bin/amixer set Master 5%-
           KEY_VOLUMEDOWN  2      /usr/bin/amixer set Master 5%-
I think the files will only be sourced if they end with ".conf".
Once you have put them in that directory, restart the daemon:

Code: Select all

sudo invoke-rc.d triggerhappy restart
Last edited by mnoit on Wed Sep 04, 2013 12:02 pm, edited 1 time in total.

User avatar
solar3000
Posts: 1059
Joined: Sat May 18, 2013 12:14 am

Re: Keyboard volume controls

Tue Sep 03, 2013 8:58 pm

OK the dump gives me this:

Code: Select all

EV_KEY  KEY_VOLUMEUP    1       /dev/input/event1
# KEY_VOLUMEUP  1       command
EV_KEY  KEY_VOLUMEUP    0       /dev/input/event1
# KEY_VOLUMEUP  0       command
EV_KEY  KEY_VOLUMEDOWN  1       /dev/input/event1
# KEY_VOLUMEDOWN        1       command
EV_KEY  KEY_VOLUMEDOWN  0       /dev/input/event1
# KEY_VOLUMEDOWN        0       command
I've tried various combinations in the triggerhappy.d/suspend.conf file but nothing happened.
from the --dump, it looks like pressing 'x' key can run some command. So I tried that and I ran some random x program with the two volume keys but nothing happened.

So lets start with this, lets get the volume up and down keys to run anything at all.
Antikythera

User avatar
solar3000
Posts: 1059
Joined: Sat May 18, 2013 12:14 am

Re: Keyboard volume controls

Wed Sep 04, 2013 1:56 pm

OK I've solved it.

Keyboard volume up and down on Raspbian and LXDE:

Edit file ~/.config/openbox/lxde-rc.xml
Insert this code in the keyboard section:

Code: Select all

 
<keybind key="XF86AudioRaiseVolume">
<action name="Execute">
<command>amixer set PCM 250+</command>
</action>
</keybind>

<keybind key="XF86AudioLowerVolume">
<action name="Execute">
<command>amixer set PCM 250-</command>
</action>
</keybind>

 
reboot.
Antikythera

User avatar
dev_bot
Posts: 8
Joined: Mon Jun 06, 2016 4:16 pm

Re: Keyboard volume controls

Thu Dec 29, 2016 4:38 pm

solar3000 wrote:OK I've solved it.

Keyboard volume up and down on Raspbian and LXDE:

Edit file ~/.config/openbox/lxde-rc.xml
Insert this code in the keyboard section:

Code: Select all

 
<keybind key="XF86AudioRaiseVolume">
<action name="Execute">
<command>amixer set PCM 250+</command>
</action>
</keybind>

<keybind key="XF86AudioLowerVolume">
<action name="Execute">
<command>amixer set PCM 250-</command>
</action>
</keybind>

 
reboot.
Since the Raspbian Pixel update, the file is lxde-pi-re.xml . I found that out the hard way! :D
"Ooh, pie!"

There are 10 types of people: those who understand binary and those who don't.

SkyGiG
Posts: 1
Joined: Mon Apr 24, 2017 7:11 pm

Re: Keyboard volume controls

Mon Apr 24, 2017 8:13 pm

I used solar3000's solutions with my logictech k400 plus.

First I used xev to show mute and volume keys values when I pressed down.

Then I typed amixer into a shell to show the name of sound system, (I didn't have PCM). Its important the range of values that amixer prints, in my case it was 0-65000 so I used 2500+- instead of 250.

amixer set Master 2500+

I wrote that into a shell to test and workeds fine so with all this information I modified lxde-pi-re.xml as wrote dev_bot.

Return to “Beginners”