Skip to content
Roger Dahl edited this page Apr 2, 2017 · 1 revision

Fix volume controls on Logitech USB Headset

On my Linux Mint 18 box, the volume buttons on my Logitech USB Headset would control the volume for the default output device (my speakers) instead of the headset volume. This is a fix, using triggerhappy

  • Install triggerhappy

    • $ sudo apt install triggerhappy
  • Find out which input device the headset volume keys are listed as

    • $ sudo thd --dump /dev/input/event*

    • Press the volume buttons on the headset and note the device for the events, such as /dev/input/eventX

    • Below, replace /dev/input/eventX with the actual device

  • Find out what's listening to those events

    • $ lsof | grep /dev/input/eventX
  • In my case, there were two listeners, Xorg and acpid. First, I tried turning off the acpid service

    • $ sudo service acpid stop
  • But pressing the headphone volume buttons still controlled the default output device. So I enabled the acpid service again

    • $ sudo service acpid start
  • Then, I searched the Xorg log for references to /dev/input/eventX

    • grep -C 10 /var/log/Xorg.0.log /dev/input/eventX | less
  • And found

    [    21.577] (II) config/udev: Adding input device Logitech Logitech USB Headset (/dev/input/eventX)
    [    21.577] (**) Logitech Logitech USB Headset: Applying InputClass "evdev keyboard catchall"
    [    21.577] (II) Using input driver 'evdev' for 'Logitech Logitech USB Headset'
    [    21.577] (**) Logitech Logitech USB Headset: always reports core events
    [    21.577] (**) evdev: Logitech Logitech USB Headset: Device: "/dev/input/eventX"
    [    21.577] (--) evdev: Logitech Logitech USB Headset: Vendor 0x46d Product 0xa0b
    [    21.577] (--) evdev: Logitech Logitech USB Headset: Found keys
    [    21.577] (II) evdev: Logitech Logitech USB Headset: Configuring as keyboard
    [    21.577] (**) Option "config_info" "udev:/sys/devices/pci0000:00/0000:00:07.1/0000:29:00.3/usb5/5-3/5-3:1.3/0003:046D:0A0B.0001/input/input5/event2"
    [    21.577] (II) XINPUT: Adding extended input device "Logitech Logitech USB Headset" (type: KEYBOARD, id 12)
    [    21.577] (**) Option "xkb_rules" "evdev"
    [    21.577] (**) Option "xkb_model" "pc105"
    [    21.577] (**) Option "xkb_layout" "us"
    
  • In other words, Xorg discovers the headphone volume buttons and assigns the regular keyboard driver to handle them. So the volume buttons on the headset end up working exactly like the volume media buttons on a regular keyboard, controlling the default output device

  • Tell Xorg to ignore the Logitech volume keys

    • Edit /etc/X11/xorg.conf

    • Insert a section like this

      Section "InputClass"
          Identifier "Logitech Logitech USB Headset"
          MatchUSBID "046d:0a0b"
          Option "Ignore" "on"
      EndSection
      
      
    • Notes

      • The USB ID numbers are copied from the "Vendor 0x46d Product 0xa0b" line in the Xorg log file above. Your USB ID may differ
        • Also note that the "0x" was removed, and zero padding was added as necessary to get to 4 hex digits in each number
      • A logical spot for the new section is under any InputDevice sections but it probably doesn't matter where it goes
  • Restart X by logging out and logging back in

  • Try pressing the headset volume keys. They should now be ignored

  • Next step is to assign our own actions to these keys

  • List all sound outputs (sinks), ignoring monitoring outputs

    • $ pactl list short | grep output | grep -v monitor
  • Pick the sink name of the headset output, e.g.

    • alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo
    • Replace the sink name below with your actual one
  • Test adjusting the volume from the command line

    • Open the PulseAudio Volume Control

      • $ pavucontrol
    • Locate the volume slider for the headphones in the Output devices tab and note the volume percentage

    • Increase the volume by 5% from the command line

      • $ pactl set-sink-volume alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo "+5%"
    • Verify that the volume increased in the PulseAudio Volume Control

  • Now we have the commands required for increasing and decreasing the volume

  • Add triggers for triggerhappy

    • $ sudo nano /etc/triggerhappy/triggers.d/usb-headset-volume.conf

      KEY_VOLUMEUP            1       DISPLAY=:0 /usr/bin/pactl set-sink-volume alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo "+5%"
      KEY_VOLUMEDOWN          1       DISPLAY=:0 /usr/bin/pactl set-sink-volume alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo "-5%"
      
  • There are two additional issues that need to be fixed

    • By default, triggerhappy listens to all devices under /dev/input/event*. This causes the regular keyboard volume media keys to also adjust the headset volume

    • By default, triggerhappy runs under the nobody user. This user does not have permissions to access PulseAudio, so the pactl command fails

    • To fix these, edit the service script

      • edit /etc/init.d/triggerhappy

        • In DAEMON_ARGS, change

          • nobody -> your user

          • /dev/input/event* -> /dev/input/eventX

  • Start triggerhappy

    • $ systemctl daemon-reload
    • $ sudo service triggerhappy restart
Clone this wiki locally