Advertising

Welcome to SparkyLinux forums
Zapraszamy również na polsko-języczne Forum https://forum.linuxiarze.pl

How to get keyboard volume buttons working?

Started by PNWDrew, May 18, 2015, 07:44:52 PM

Previous topic - Next topic

PNWDrew

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



way12go

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...
Success gives birth to success? Failure gives birth to failure? - Sagar Gorijala.

way12go

Success gives birth to success? Failure gives birth to failure? - Sagar Gorijala.

PNWDrew

Quote from: way12go 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

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?

way12go

No you don't need it. You can also set resolution using this



Open Terminal, run

Quotesudo 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/

Success gives birth to success? Failure gives birth to failure? - Sagar Gorijala.

PNWDrew

Quote from: way12go on May 20, 2015, 06:28:17 AM
No you don't need it. You can also set resolution using this



Open Terminal, run

Quotesudo 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.

way12go

You mentioned backlight program, it's for brightness.
Success gives birth to success? Failure gives birth to failure? - Sagar Gorijala.

way12go

#7
Quotesudo apt-get install xfce4-volumed gstreamer0.10-alsa

You'll need some prerequisite packages:

Quotesudo 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.



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
Success gives birth to success? Failure gives birth to failure? - Sagar Gorijala.

PNWDrew

Quote from: way12go on May 20, 2015, 08:27:04 AM
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

way12go

Success gives birth to success? Failure gives birth to failure? - Sagar Gorijala.

PNWDrew

Quote from: way12go on May 21, 2015, 05:49:06 PM
Does my previous post work?

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

way12go

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.
Success gives birth to success? Failure gives birth to failure? - Sagar Gorijala.

way12go

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.

Success gives birth to success? Failure gives birth to failure? - Sagar Gorijala.

PNWDrew

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).

View the most recent posts on the forum