» pages: blog | About Me | projects | Resume |

toggle headphones/speakers key via xbindkeys

linux — davidb — December 5th, 2008

I’ve been using xbindkeys for a few years now to create keyboard shortcuts on my computer. It’s super useful, and a quite easy way to get the multimedia keys on my keyboard to do what I want. A quick tutorial on xbindkeys:

First, install it

sudo apt-get install xbindkeys

Then, run the following in a console to grab input for a specific key press combination.

xbindkeys -mk

Select the window that pops up, type the key, and on the console you should see some output something like this:

"(Scheme function)"
    m:0x10 + c:98
    Mod2 + Up

Copy and paste that into your .xbindkeysrc and change “(Scheme function)” to “foo” where foo is the command you would like executed. Quit that, run xbindkeys, and whenever you type that key combination, foo will be executed.

So, a few months ago I bought a pair of 2.1 speakers for my computer. In the past I’ve only used headphones, so being able to lie in bed and watch movies/listen to music was very nice. However, I tend to work late into the night and my room mates don’t exactly appreciate my loud music. So, I still use headphones occasionally. The problem is I don’t want to have to unplug the speakers and plug them back in every time I want to use headphones. Luckily, my sound card has multiple line outs. So, a combination of amixer and xbindkeys allows me to simply hit a button on my keyboard to switch between the headphones and the speakers.

Here’s the snippet of my .xbindkeysrc that does this work:

# favorites button - toggle headphones/speakers
"amixer set Surround toggle; amixer set Front toggle"
m:0x10 + c:230
Mod2 + NoSymbol

0 Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

(c) 2010 david-brenner.net | powered by WordPress with Barecity