Saturday, November 17, 2007

Global Media Keyboard Shortcuts for Bongo

I am now currently on hour 9 of my current stay in the Electrical Engineering lab of Barus & Holley, and going a little insane. Luckily, I figured out a neat little trick that will make my media playing under Bongo that much more pleasant.

In Ubuntu, at least for me, the media keys on my Thinkpad T60 work great with Rhythmbox without any fancy configuration. This is great if I wanted to use that particular player, but I have bigger plans. I want Emacs to be my jukebox as well.

Unfortunately, those lovely keyboard shortcuts do not work with Bongo by default. Luckily, with the help of KeyTouch, I was able to get it working. KeyTouch is a fairly straightforward program, and there is plenty of additional info available here.

What I learned is that you have to disable the shortcuts you want to manage with KeyTouch in Ubuntu's System > Preferences > Keyboard Shortcuts since they will take precedence over anything you define in KeyTouch.

In KeyTouch, you will have a list of keys and their actions. Let's say we want to map the play/pause command for Bongo to the "Fn-Down" combination (this happens to be the play/pause key on my laptop). We can give KeyTouch a program to execute, but which one to do? We already have a running Emacs instance, so opening a new one would be just wrong. Whatever shall we do?

Enter EmacsClient. It's basic goal is to allow the environment to set it as $EDITOR variable and open files in an existing Emacs instance. One lovely thing about it is that it allows invocation of arbitrary elisp expressions as well.

Once you have it set up, you can use the following to pause the currently playing Bongo file:

emacsclient -e '(bongo-pause/resume)'

To pause or resume (shocker, I know). The elisp functions bongo-next and bongo-previous allow you to jump forward or back through your current playlist.

Now I have one less reason to ever leave trusty ole Emacs behind. Stay tuned for when I switch all of my email over from Gmail to Emacs!

No comments:

Post a Comment