Headphone recognition

Questions about hardware,drivers and peripherals
Forum rules
Before you post please read how to get help
User avatar
Level 5
Level 5
Posts: 933
Joined: Fri Feb 06, 2009 5:05 pm
Location: Boston College

Headphone recognition

Postby Kaye » Sat Mar 07, 2009 10:59 am

Hey everyone,

Since I have to go into ossxmix and mute my speakers manually every time I plug in my headphones, I wrote a small bash script so that I can simply hit <Control>h and mute/unmute my speakers:

Code: Select all


MODE=$(ossmix jack.int-speaker.mode)
if [ "$MODE" = "Value of jack.int-speaker.mode set to mix2" ]; then
    ossmix jack.int-speaker.mode input
    ossmix jack.black.mode4 input
    ossmix jack.int-speaker.mode mix2
    ossmix jack.black.mode4 mix2

(Or something along those lines, I'm on another system right now).
The script works perfectly, but I was wondering if it were possible to take it to the next level. Is there any way for me to monitor whether or not headphones are plugged in, and have this script run every time they're plugged in or removed? I would be happy enough with this hack, it would at least make me feel like a driver was running things for me :)

Thanks in advance,
"In somnis veritas"
Antivirus or defragging?

Level 23
Level 23
Posts: 18703
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Re: Headphone recognition

Postby Husse » Sun Mar 08, 2009 10:22 am

That is a tough one
Because if your headphones don't switch of your speakers the chances are that they are not recognised
And even if they were you'd have to do something very "basic" (like an udev rule)
You could try to run

Code: Select all

lsmod | grep snd

with the headphones plugged in an not plugged in
I don't think there's a difference, but who knows (I have only got USB headphones so I can't check)
It's no longer just a mechanical thing - plugging in triggers a reaction of some kind that should be dealt with by Linux
Some node appearing or disappearing...
Don't fix it if it ain't broken, don't break it if you can't fix it

Return to “Hardware Support”

Who is online

Users browsing this forum: Bing [Bot] and 4 guests