You are not logged in.
Hello community,
how do i make my computer to execute a short script, when a audiojack is inserted?
I would like to play a short jingle, when i plug in my headphones, just like my old Sony Ericsson mobile some years ago :-)
I'm using Arch Linux 3.3.6-1 on my Thinkpad X201
ALSA or Pulseaudio already notice plugged headphones and store different gains for each output.
Any ideas?
Thank you in advance
Last edited by pforcht (2012-05-23 14:50:16)
Offline
Probably start with CONFIG_SND_HDA_INPUT_JACK in the kernel config.
Offline
Hi brebs,
thanks for your reply. How can I find out, if this flag is enabled in my kernel?
I'm not compiling my kernel on my own - I use the precompiled version from Repository.
Offline
To see config of current kernel:
zgrep JACK /proc/config.gz
Offline
Very nice - already enabled i guess (?): CONFIG_SND_HDA_INPUT_JACK=y
Anyway I don't know how to capture these events. For ACPI I already know, but the audiojack doesn't create any ACPI events.
I found https://wiki.archlinux.org/index.php/Ja … ner_Daemon but it does not exist in AUR anymore.
Any hints?
Last edited by pforcht (2012-05-21 14:13:55)
Offline
Hi pforcht,
are you sure about that acpi thing? I searched the mailing list and this is what i found:
alexander.r@gmx.com via archlinux.org
Apr 27
to aur-general
Please remove following packages:
https://aur.archlinux.org/packages.php?ID=57515 (jackeventcmd-git)
https://aur.archlinux.org/packages.php?ID=57514 (jacklistener-git)
https://aur.archlinux.org/packages.php?ID=57513 (jacknotifier-git)
as jack (un)plug event handling is implemented in the latest acpid version.
For me this is true:
[root@myhost]# acpi_listen
jack/headphone HEADPHONE plug
jack/headphone HEADPHONE unplug
So it should be possible to create an acpi handler for this event.
If this is for some reason not working, here are some ideas:
1. check (evtest), which input device is used for your headphone jack and write your own listener
2. /proc/asound/card0/codec#0 (in my case) stores the information about the "plug status"
masutu:~$ cat /proc/asound/card0/codec\#0 > unplugged
masutu:~$ cat /proc/asound/card0/codec\#0 > plugged
masutu:~$ diff unplugged plugged
139c139
< Pin-ctls: 0x40: OUT
---
> Pin-ctls: 0x00:
Maybe you can use this for your event handler
3. the jacklistener repo is still up, did you try it?
Offline
YEAH! Than you very much.
You are right, it is implemented by ACPI. I just got used to it to watch for Events in /var/log/acpi or /var/log/everything. I forgot about acpi_listen.
Now I can make these Scripts very easy.
Btw: it also recognizes a pluged/unplugged microphone jack:
jack/microphone MICROPHONE plug
jack/microphone MICROPHONE unplug
Once again - Thank you, and the kind ArchLinux community
Edit: For someone else with this issue, here my acpi scripts:
Add a file (named as you wish) to directory /etc/acpi/events/ with following text:
event=jack/*
action=/PATH/TO/YOUR/CUSTOM/ACPI/SCRIPTS/soundevents.sh %e
After that on every jack/* event the script 'soundevents.sh' is being executed, passing the event as parameter (%e).
My soundevents.sh currently includes:
#!/bin/bash
SndHeadPlug="/path/to/soundfile.mp3"
SndHeadUnplug="/path/to/an/other/sound.wav"
SndMicPlug=""
SndMicUnplug=""
Player="mplayer -really-quiet"
case "$1" in
jack/headphone)
case "$3" in
plug)
$Player $SndHeadPlug
;;
unplug)
$Player $SndHeadUnplug
;;
esac
;;
jack/microphone)
case "$3" in
plug)
$Player $SndMicPlug
;;
unplug)
$Player $SndMicUnplug
;;
esac
;;
esac
Last edited by pforcht (2012-05-23 14:49:56)
Offline