58

My keyboard has dedicated keys to change the audio volume and to mute/unmute audio. How can I make these work in XFCE?

Nova
  • 2,895

5 Answers5

77
  1. Right click a panel -> Panel submenu -> Add New Items...
  2. Add an instance of PulseAudio Plugin
  3. Right click the icon that just appeared in your panel and click "Properties". Make sure "Enable keyboard shortcuts for volume control" is enabled.

You may have to install the PulseAudio Plugin first. In Debian and Debian-based distributions, the package is called xfce4-pulseaudio-plugin.

Nova
  • 2,895
  • 3
    For future searchers: this solved my problem in a Thinkpad X1 when upgrading from Debian jessie to Debian stretch – bnewbold Aug 06 '17 at 06:04
  • 2
    nice. Worked for my setup: Ubuntu 18 + xfce4 – Zeta.Investigator Aug 21 '18 at 09:56
  • 2
    I dont want an item in my panel just for working hotkeys. Pretty strange solution – phil294 Oct 14 '18 at 00:36
  • 6
    @Blauhirn You can instead install xfce4-volumed-pulse (which appears to be packaged as xfce4-volumed in Ubuntu 18.04) to get hotkey support without a panel plugin. Launchpad – Jon Oct 26 '18 at 08:26
  • 1
    This fixed the problem for me in Fedora 30. – Paul May 11 '19 at 22:04
  • If you don't have Multimedia keys here's a suggestion for keybindings: Volume Up ALT + PageUp, Volume Down ALT + PageDown, Mute ALT + Pos1.

    Though it is more of a Windows standard to use the PageUp and Down keys for volume it is mapped in a lot of software, too. Still, Firefox uses STRG + Page Up to switch between Tabs so just use ALT.

    – somethis Aug 14 '19 at 09:41
  • Installing xfce4-volumed was what really fixed my problem, as @Jon suggested. – Alfonso Nishikawa Jan 03 '20 at 21:44
  • Worked great on Mint 19 with a laptop that doesn't have media keys. I set it to Alt + Up and Alt + Down. This solution even shows the volume up and down indicator when pressed. Perfect! – Trevor Nov 15 '22 at 19:15
36

1.-Configuration

2.-Keyboard

3.-Application shortcuts

4.-Add

amixer -D pulse set Master 5%+     --> (Volume Up)
amixer -D pulse set Master 5%-     --> (Volume Down)
amixer -D pulse set Master toggle  --> (Mute/Unmute)

Update:

The parameter -D pulse was added to the command so it would work with current versions of xfce4 using pulseaudio for sound.

enter image description here

dr jimbob
  • 370
  • Adding the mute/unmute toggle only mutes the audio. When I press the same key combo, the audio is not unmuted. On Ubuntu 18.04 + xfce4. The volume up and down commands works well. – Akshay Gaur Sep 11 '18 at 14:55
  • I've used Enable keyboard shortcuts for volume control = Off, combined with amixer set Master 20%- command on Mute hotkey, to disable Mute hotkey and instead of Mute do a rapid volume reduce. Its more convenient than Mute :) – idonnie Feb 02 '19 at 10:06
  • 1
    Ubuntu 18.04 / xfce4 I had to use amixer -D pulse set Master 15%- without the "-D pulse" the volume did not change. – user3183018 Jul 10 '19 at 09:53
  • 1
    Use "amixer -D pulse set Master 1+ toggle" to make also unmute working – Panoptik Nov 19 '19 at 09:25
  • Thanks. Also used this to toggle the microphone: amixer -D pulse set Capture toggle --> (Mic Mute/Unmute) – Mahmoud Elagdar Jun 08 '23 at 19:50
22

Please notice, that both answers are correct, but each depend on different packages for the sound management. Erik here uses pulseaudio while Samuel Loza's answer implies, that alsamixer is used.

xfce4-pulseaudio-plugin

  1. Right click a panel -> Panel submenu -> Add New Items...
  2. Add an instance of PulseAudio Plugin
  3. 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.
  4. Open the configuration for your keyboard shortcuts and add the following commands:
    pactl -- set-sink-volume @DEFAULT_SINK@ +10% # raise volume by each 10% (more than 100% possible, might distort the sound)
    pactl set-sink-volume @DEFAULT_SINK@ -10% # reduce volume by each 10%
    pactl set-sink-mute @DEFAULT_SINK@ toggle # mute/unmutes audio

alsamixer (compare Samuel's answer)

  1. Check if alsamixer is working as your sound management.
  2. Go see the configuration for keyboard shortcuts and edit:
    amixer set Master 10%+ # raise volume by each 10 %
    amixer set Master 10%- # reduce volume by each 10 %
    amixer set Master toggle # mute/unmute audio

The first solution works for me on Debian stretch, I had problems with the sound after the upgrade from jessie. The settings work while using headphones as well. One can adapt the amount of increase/decrease in % freely.

Duplicated questions:
How to increase or decrease volume in Xfce with keyboard shortcuts? (English, NA)
Muting and unmuting sound with mutebutton (English, Debian jessie)

Further links:
https://wiki.debian.org/Sound (English, Debian)
https://bugs.launchpad.net/xfce4-volumed/+bug/883485 (English, Debian+Ubuntu)
https://askubuntu.com/questions/652890/shortcuts-volume-specific-output (English, Ubuntu 15.04)
Lower or increase pulseaudio volume on all outputs (English, Debian sid)
https://mysudo.wordpress.com/2015/03/27/unmute-pulseaudio-sound-in-xfce-debian-jessie/ (German, Debian jessie)
https://ubuntuforums.org/showthread.php?t=2342661 (English, Ubuntu)

Sebastian
  • 329
  • 1
    Alsamixer should always work, even when using Pulseaudio – Nova Sep 27 '18 at 13:10
  • 1
    pactl -- set-sink-volume @DEFAULT_SINK@ +10% with @DEFAULT_SINK@ instead of 0 as mentioned in the answer below helped me. I just add this as a comment so that other people find the remark immediately. – exchange Apr 28 '20 at 11:40
4

Trying to use pactl -- set-sink-volume 0 +10% did not work for me.

Using @DEFAULT_SINK@ instead of 0 as the sink worked for me.

Example:

pactl -- set-sink-volume @DEFAULT_SINK@ +10%

bot42
  • 51
2

Deleting the files in ~/.config/pulse then running the following in the terminal should fix it:

pulseaudio -k

You may need to restart your sound playing apps after that, and if pulseaudio doesn't restart on its own, this will restart it:

pulseaudio --start

Okay. At the bottom of the window click on Add. In the window that open for the command enter this:

amixer -D pulse sset Master 3%+ unmute

Now click on Ok, then it'll ask you to press the key(s) you want to assign to that command. Just press your volume up button and it should be done.

You can then repeat the process using this for the volume decrease button:

amixer -D pulse sset Master 3%- unmute

If you have a mute button as well, repeat one more time using this:

amixer -D pulse sset Master toggle

In case your permissions got messed up, this terminal command will fix them (I don't know any other way to do this, sorry!):

sudo chown -Rc $USER:$USER $HOME