2

I'm using acpid to detect when my headphones are plugged in. According to acpid_listen, the relevant events are

jack/headphone HEADPHONE unplug
jack/headphone HEADPHONE plug

I created the file /etc/acpi/events/headphone_jack like this:

event=jack/headphone.*
action=/etc/acpi/actions/headphone.sh "%e"

The event still doesn't trigger if I use jack[ /]headphone instead. The script /etc/acpi/actions/headphone.sh looks like this:

amixer set Master off

In other words, every time the headphones are plugged in or unplugged, the volume is muted. This amixer command works in the terminal. I restarted the acpid service with sudo /etc/init.d/acpid reload, but the event still isn't triggering.

What am I doing wrong? I'm using Debian 10 ("buster") x64 on a Thinkpad X1 Carbon 4th generation.

2
  • 1
    The script might need "#!/bin/sh" on the first line, and it must of course be executable. Commented Dec 29, 2019 at 2:32
  • I'm embarrassed that I forgot to make the script executable. I use #!/usr/bin/env bash as the shebang, but otherwise, your answer is perfect. Thank you.
    – Michael A
    Commented Dec 29, 2019 at 14:51

1 Answer 1

2

The script might need "#!/bin/sh" on the first line, and it must of course be executable.

It's a not un-common mistake to miss or forget the latter, which is fixed with

$ chmod a+x /path/to/script

A more exhaustive description of all this is found in the standard manual pages with:

$ man execve

On Debian systems those manual pages have nowadays been relegated out of the standard collection, and you may need to install them from the manpages-dev package with:

# apt-get install manpages-dev

Note that the package installation requires root access, unless you have some other means of installing packages.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .