LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Getting keyboard volume buttons to work in LXDE (https://www.linuxquestions.org/questions/slackware-14/getting-keyboard-volume-buttons-to-work-in-lxde-4175623496/)

Lysander666 02-10-2018 11:14 AM

Getting keyboard volume buttons to work in LXDE
 
I had a read of this topic:

https://www.linuxquestions.org/quest...ns-4175564374/

in order to get the keyboard volume buttons to work on Slack 14.2 32bit.

Now, first things first, I know the key binding is detected since xev shows me that pressing the volume key bindings gives

Code:

KeyRelease event, serial 48, synthetic NO, window 0x3600001,
    root 0x7e, subw 0x0, time 1134498, (659,79), root:(661,128),
    state 0x0, keycode 122 (keysym 0x1008ff11, XF86AudioLowerVolume), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyPress event, serial 48, synthetic NO, window 0x3600001,
    root 0x7e, subw 0x0, time 1135209, (659,79), root:(661,128),
    state 0x0, keycode 123 (keysym 0x1008ff13, XF86AudioRaiseVolume), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False


though they don't seem to be work.

My soundcard is sink 0 according to

Code:

lysander@lysurfer_viii:~$ pamixer --list-sinks
Sinks:
0 "alsa_output.pci-0000_00_1b.0.analog-stereo" "Built-in Audio Analog Stereo"

so I input the following into the <keyboard> section of rc.xml:

Code:

  <keybind key="XF86AudioRaiseVolume">
    <action name="Execute">
      <execute>pamixer --sink 0 -i 5</execute>
    </action>
  </keybind>
  <keybind key="XF86AudioLowerVolume">
    <action name="Execute">
      <execute>pamixer --sink 0 -d 5</execute>
    </action>
  </keybind>
  <keybind key="XF86AudioMute">
    <action name="Execute">
      <execute>pamixer --sink 0 -t</execute>
    </action>
  </keybind>

but it has had no effect. Does anyone know what I could be doing wrong?

suprateam 02-10-2018 12:48 PM

Hello,

Did you try manually the command in a terminal to make sure it works ?

I'm not using LXDE ( AwesomeWM ) but I do use the same method.
Here are the commands I'm using if it can help:

Code:

XF86AudioLowerVolume => "amixer -q sset PCM 2%-"
XF86AudioRaiseVolume => "amixer -q sset PCM 2%+,
XF86AudioMute => "amixer -q sset PCM toggle"


Lysander666 02-10-2018 12:51 PM

Hmm, when I try one of those I get:

Code:

bash: XF86AudioLowerVolume: command not found
So it recognises the binding through xev but not the command, which is interesting.

suprateam 02-10-2018 01:20 PM

XF86AudioLowerVolume is not a command. It's just the `key` representation

what is the result of those command in a terminal ? does it increase/decrease the volume as expected ?
Code:

pamixer --sink 0 -d 5
or
Code:

pamixer --sink 0 -i 5

Lysander666 02-10-2018 01:24 PM

Yes - both of those work in lowering and raising the volume. So something is getting lost in applying the working command [e.g. pamixer --sink 0 -i 5] to the keys.

Lysander666 02-10-2018 02:28 PM

Found it - the entry is:

Code:

<keybind key="XF86AudioRaiseVolume">
    <action name="Execute">
      <command>pamixer --sink 0 -i 5</command>
    </action>
  </keybind>
  <keybind key="XF86AudioLowerVolume">
    <action name="Execute">
      <command>pamixer --sink 0 -d 5</command>
    </action>
  </keybind>
  <keybind key="XF86AudioMute">
    <action name="Execute">
      <command>pamixer --sink 0 -t</command>
    </action>
  </keybind>

which has to be added to the <keyboard> section of .config/openbox/lxde-rc.xml - then logout and login.

The issue I had was that [as well as the slightly incorrect 'execute' tag] I was editing /etc/xdg/openbox/rc.xml directly, which should not be done.

Lysander666 03-28-2018 05:39 AM

Sorry to resurrect this, but this function has stopped working for a while now, I can no longer use the keyboard buttons to adjust the audio volume. I have no idea what the issue could be. I wonder if it has anything to do with new packages that have been upgraded or installed, but since the file

.config/openbox/lxde-rc.xml

is unchanged I have no idea what such packages could be or why they could do so. Any suggestions would be most welcome.

ponce 03-28-2018 06:13 AM

if you issue the same commands to which you have associated keys for in a terminal, do they have effect?

Lysander666 03-28-2018 12:46 PM

Quote:

Originally Posted by ponce (Post 5836407)
if you issue the same commands to which you have associated keys for in a terminal, do they have effect?

Hmm, good idea. I'm just getting the response

Code:

Connection error
Wonder what could be causing that. I thought it could be because I enabled alsaequal/dmix, but I removed the code from .asoundrc and logged out/in, and I'm still getting the paerror.

EDIT: I did the following re another thread, this has definitely affected my link to PA

Quote:

1) Comment these lines in asound.conf:
Code:
pcm.default pulse
ctl.default pulse
2) Append these lines to /etc/pulse/default.pa:
Code:
load-module module-alsa-sink device=dmix
load-module module-alsa-source device=dsnoop
3) Keep this line in /etc/pulse/client.conf:
Code:
autospawn = yes
So I think I see what's going on here. I wonder if there's a way to directly raise/lower the volume via ALSA.

EDIT 2 -found it

Code:

amixer set Master 5%+
I imagine replacing the old code with this would work

EDIT 3 -and it does, thank you.

Seems on this system ALSA is the way for now rather than PA.

Lysander666 07-19-2018 03:10 PM

Appending for Xfce. This answer was very useful:

https://unix.stackexchange.com/quest...in-xfce/342555

Quote:

Right click a panel -> Panel submenu -> Add New Items...
Add an instance of PulseAudio Plugin
Right click the icon that just appeared in your panel and click "Properties". Make sure "Enable keyboard shortcuts for volume control" is enabled. -> See: Sound settings -> Audio mixer will tell you what package you use. If pulseadio is used the field should tell pavucontrol.
Open the configuration for your keyboard shortcuts and add the following commands:
pactl -- set-sink-volume 0 +10% # raise volume by each 10% (more than 100% possible, might distort the sound)
pactl -- set-sink-volume 0 -10% # reduce volume by each 10%
pactl -- set-sink-mute 0 toggle # mute/unmutes audio

Config for keyboard shortcuts in Xfce = settings > keyboard > shortcuts

Notice the difference between pavu and alsa in the answer which accounts for my volume stopping working initally in LXDE since I have disabled access to Pulse in my other Slack install. Hopefully someone will find this useful.

vasilis74 04-28-2020 08:05 PM

Quote:

Originally Posted by Lysander666 (Post 5836569)
EDIT 2 -found it

Code:

amixer set Master 5%+

I confirm it works on my desktop Devuan ASCII.
Many thanks @Lysander666, you really helped me!
I listen radio broadcasting, live news etc via players that have their own shortcuts. But while other programs were on the screen, I had to use the mouse to conrtol the volume from the panel volume-icon.
With:
Code:

amixer set Master 5%+
amixer set Master 5%-
amixer set Master toggle

in 3 keyboard shortcuts (XFCE>Settings>Keyboard>Shortcuts>+Add) thinks are much easier, thanks again!


All times are GMT -5. The time now is 07:16 PM.