Author Topic: How to get keyboard volume buttons working?  (Read 1384 times)

Offline PNWDrew

  • Jr. Member
  • **
  • Posts: 50
How to get keyboard volume buttons working?
« on: May 18, 2015, 07:44:52 pm »
HI all,
I'd like to get the vol up/down/mute buttons on my Logitech K360 wireless keyboard working.  I use alsamixer for audio, though changing to something I didn't have to reset repeatedly would be nice.
I can see the keypresses in xev.  I just don't know what to do with that info; or even if this is a good way to do it. 
Ideally it would be global, so that any time I press the key I get a volume change, regardless of what window I  am focused on.

EG: Volume down:
    KeyPress event, serial 48, synthetic NO, window 0x3c00001,
    root 0xd3, subw 0x0, time 485398980, (331,-420), root:(333,475),
    state 0x10, keycode 122 (keysym 0x1008ff11, XF86AudioLowerVolume), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

Thanks,
Drew



Offline way12go

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 476
  • Saying something clever is easy,when you r stupid.
Re: How to get keyboard volume buttons working?
« Reply #1 on: May 19, 2015, 08:41:58 am »
I think keyboard keys are well supported along with on screen display OCD in XFCE and MATE desktop environments and pavroo gave a text to place inside some file when I asked about it while using LXDE. Need that text I guess...
Saying something clever is easy, when you are stupid. - Sagar Gorijala.

Offline way12go

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 476
  • Saying something clever is easy,when you r stupid.
Re: How to get keyboard volume buttons working?
« Reply #2 on: May 19, 2015, 08:45:57 am »
I searched for it and found the link, it is here...

http://sparkylinux.org/forum/index.php/topic,2997.msg5749.html#msg5749
Saying something clever is easy, when you are stupid. - Sagar Gorijala.

Offline PNWDrew

  • Jr. Member
  • **
  • Posts: 50
Re: How to get keyboard volume buttons working?
« Reply #3 on: May 20, 2015, 04:15:08 am »
I searched for it and found the link, it is here...

http://sparkylinux.org/forum/index.php/topic,2997.msg5749.html#msg5749

Thanks.  A
As usual what I'm donig is a little over my head but it is a place to start and learn something. 
So I may be able to keybind the volume functions in a similar way?  I don't need the backlight program at all do I?

Offline way12go

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 476
  • Saying something clever is easy,when you r stupid.
Re: How to get keyboard volume buttons working?
« Reply #4 on: May 20, 2015, 06:28:17 am »
No you don't need it. You can also set resolution using this



Open Terminal, run

Quote
sudo leafpad /etc/rc.local


It will ask for password. Type your password.
Then, the text editor will pop up with rc.local file opened. It contains some stuff and in the end exit 0.

Before that exit 0 line, add below commands to reduce brightness

echo x > /sys/class/backlight/intel_backlight/brightness
echo x > /sys/class/backlight/acpi_video0/brightness

choose one code - line mentioned above, that works for you.

Sometimes some distros or 32 or 64 bit have /intel_backlight or /acpi_video0

Know maximum brightness value

cat /sys/class/backlight/acpi_video0/max_brightness

Adjust brightness and to set the new adjusted brightness to default brightness

use your keyboard or backlight-app and use this command to know the value

cat /sys/class/backlight/acpi_video0/brightness      [ current brightness ]

Also visit this webpage

http://ubuntuhandbook.org/index.php/2014/04/save-screen-brightness-settings-in-ubuntu-14-04/

Saying something clever is easy, when you are stupid. - Sagar Gorijala.

Offline PNWDrew

  • Jr. Member
  • **
  • Posts: 50
Re: How to get keyboard volume buttons working?
« Reply #5 on: May 20, 2015, 07:20:53 am »
No you don't need it. You can also set resolution using this



Open Terminal, run

Quote
sudo leafpad /etc/rc.local


It will ask for password. Type your password.
Then, the text editor will pop up with rc.local file opened. It contains some stuff and in the end exit 0.

Before that exit 0 line, add below commands to reduce brightness

echo x > /sys/class/backlight/intel_backlight/brightness
echo x > /sys/class/backlight/acpi_video0/brightness

choose one code - line mentioned above, that works for you.

Sometimes some distros or 32 or 64 bit have /intel_backlight or /acpi_video0

Know maximum brightness value

cat /sys/class/backlight/acpi_video0/max_brightness

Adjust brightness and to set the new adjusted brightness to default brightness

use your keyboard or backlight-app and use this command to know the value

cat /sys/class/backlight/acpi_video0/brightness      [ current brightness ]

Also visit this webpage

http://ubuntuhandbook.org/index.php/2014/04/save-screen-brightness-settings-in-ubuntu-14-04/

I think you misunderstand me. I'm looking for volume control not brightness.

Offline way12go

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 476
  • Saying something clever is easy,when you r stupid.
Re: How to get keyboard volume buttons working?
« Reply #6 on: May 20, 2015, 08:27:04 am »
You mentioned backlight program, it's for brightness.
Saying something clever is easy, when you are stupid. - Sagar Gorijala.

Offline way12go

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 476
  • Saying something clever is easy,when you r stupid.
Re: How to get keyboard volume buttons working?
« Reply #7 on: May 20, 2015, 08:29:43 am »
Quote
sudo apt-get install xfce4-volumed gstreamer0.10-alsa

You'll need some prerequisite packages:

Quote
sudo apt-get install xfce4-volumed gstreamer0.10-alsa

xfce4-volumed is a daemon that requires the gstreamer-alsa plugin to work. Normally you would have this run on startup.

However, for testing I just ran xfce4-volumed from a lxterminal.

If you then use the standard volume control you'll see the popups - you'll also need to clear the notification envelope in the system tray to see further popups.

http://i.stack.imgur.com/Pmqzi.png
It turned out that notification daemon was not checked in my startup programs. I've got it checked again right now, and everything works...

http://askubuntu.com/questions/74230/how-to-get-xfce4-volumed-to-work-in-lubuntu
« Last Edit: May 20, 2015, 08:36:47 am by way12go »
Saying something clever is easy, when you are stupid. - Sagar Gorijala.

Offline PNWDrew

  • Jr. Member
  • **
  • Posts: 50
Re: How to get keyboard volume buttons working?
« Reply #8 on: May 21, 2015, 03:07:12 pm »
You mentioned backlight program, it's for brightness.
Thanks for the assistance.
We got off track somehow.
The backlight reference was in the link you posted. I assumed you were saying I could use a similar tactic for volume, so intended to ask if I needed the backlight program in the link to make volume buttons work. To clarify I have no need for anything involving backlight.

My goal is to get the physical volume buttons on my keyboard to function. I have the onscreen slider and can use it to control Alsa (when Alsa works). I tend to be keyboard oriented so it would be nice to use the buttons at hand.

Drew

Offline way12go

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 476
  • Saying something clever is easy,when you r stupid.
Re: How to get keyboard volume buttons working?
« Reply #9 on: May 21, 2015, 05:49:06 pm »
Does my previous post work?
Saying something clever is easy, when you are stupid. - Sagar Gorijala.

Offline PNWDrew

  • Jr. Member
  • **
  • Posts: 50
Re: How to get keyboard volume buttons working?
« Reply #10 on: May 22, 2015, 04:09:20 am »
Does my previous post work?

Nope. 
No change.  Can change vol slider with mouse but keyboard does nothing.

Offline way12go

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 476
  • Saying something clever is easy,when you r stupid.
Re: How to get keyboard volume buttons working?
« Reply #11 on: May 22, 2015, 10:46:06 am »
This is Openbox config, but you should put it into LXDE's:


Quote
~/.config/openbox/lxde-rc.xml



This is the part I use to control volume and I put it to the key bindings in the <keyboard> section:

Lower volume by 5% by pressing the lower volume button:

       
Quote
<keybind key="XF86AudioLowerVolume">
          <action name="Execute">
            <startupnotify>
              <enabled>true</enabled>
              <name>volumedown</name>
            </startupnotify>
            <command>amixer -c 0 set Master 5%- unmute</command>
          </action>
    </keybind>



Same to raise volume


Quote
<keybind key="XF86AudioRaiseVolume">
          <action name="Execute">
            <startupnotify>
              <enabled>true</enabled>
              <name>volumeup</name>
            </startupnotify>
            <command>amixer -c 0 set Master 5%+ unmute</command>
          </action>
    </keybind>



Mute/unmute volume

Quote
<keybind key="XF86AudioMute">
          <action name="Execute">
            <startupnotify>
              <enabled>true</enabled>
              <name>volumedown</name>
            </startupnotify>
            <command>amixer -c 0 set Master toggle</command>
          </action>
    </keybind>

This even works with Pulseaudio enabled.
Saying something clever is easy, when you are stupid. - Sagar Gorijala.

Offline way12go

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 476
  • Saying something clever is easy,when you r stupid.
Re: How to get keyboard volume buttons working?
« Reply #12 on: May 22, 2015, 10:48:06 am »
Second method:

 edit lxde keyboard volume shortcuts with xbindkeys

    1. install xbindkeys in Synaptic or in terminal: sudo apt-get install xbindkeys xbindkeys-config

    2. execute this in terminal: xbindkeys --defaults > ~/.xbindkeysrc (to create the necessary file)

    3. to open xbindkeys GUI, execute this in terminal: xbindkeys-config

    4. press the "New" button on bottom to create a new keybinding

    5. the basics:

    Name: Mute
    Action: amixer sset Master toggle

    Name: Increase volume
    Action: amixer sset Master 1+ unmute

    Name: Decrease volume
    Action: amixer sset Master 1- unmute

    6. after entering each "Name/Action" pair, press the "Get Key" button on right>>a blank white window will open (you may need to maximize it), press the key or combination of keys you want, and it will capture it for you; then hit the "Apply" button on right

    7. go to the "File" tab in the upper left corner and hit "Save to default File" in the dropdown menu

    8. add "xbindkeys &" to your autostart.sh file (you'll have to look for it in your distro) so it always runs on startup (this link might help http://peppermintos.net/viewtopic.php?f=8&t=5043)

    Finished.

Saying something clever is easy, when you are stupid. - Sagar Gorijala.

Offline PNWDrew

  • Jr. Member
  • **
  • Posts: 50
Re: How to get keyboard volume buttons working?
« Reply #13 on: May 23, 2015, 03:44:37 am »
way12go - thanks for the suggestions, I'll try as soon as I get the more pressing problem of no video driver solved (see my other thread).