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!

Friday, November 16, 2007

Many TeXnicalities

So it has been a while since my last post. Life has been busy.

Specifically I spent most of last weekend dancing and all of this week working. Starting at about 3:00PM on Friday, November 9th and lasting until about 8:00PM on Sunday, I was doing some form of dance. It started with about an hour of Swing practice with Sarah for another showing of our Aladdin piece followed by the actual performance of it at 5. After that I had an hour of free time before Ballroom practice. You see, there was a competition Sunday, so every free moment I could find was spent meeting with partners.

After that, rather than take the smart route out and go to sleep, I made the long trek over to Machado for about three hours of... dancing.

Saturday was similar. I was meeting with ballroom partners up until it was time to prepare for the one and only SexPowerGod. While that may not have been purely dancing per se, it was most definitely tiring. After that, I had two hours to shower and change into something halfway respectable for the Brown Ballroom Competition for which I had to leave at 5:30AM. Being the largest single-day ballroom comp on the east coast, it went for a while and took the last bits of energy out of me until I could not even successfully point a video camera at stationary dancing couple.

My exhausting weekend aside, this post is about the glories of LaTeX. I picked it up sometime last year when CS22 suggested that all homework be done with it and have become so hooked on it that I almost wrote a $ before a mathematical equation in class today.

For those of you who don't know it, LaTeX is what you would turn to if you feel that word processing should be a subset of programming or feel the need to use Emacs for all aspects of their lives (I added music player to that list last night). Rather than pressing Ctrl-B to make text bold, you would write something like this:

\textbf{Bold text!}

The main point of this post is to gush over two related discoveries I recently made regarding LaTeX and Emacs. They are WhizzyTeX and Active-DVI.

WhizzyTeX is a minor mode for LaTeX editing in Emacs which opens an external viewer to mirror changes made to the source file in real time. So as you type, the dvi file gets update, AUTOMAGICALLY! For plain text this is not that big of a deal, but for complicated mathematical expressions or manipulation of parameters to get a look right, this cuts down on the edit-compile-review loop which can suck time away from creating masterful works. It also has the benefit of real-time error checking beyond what AucTeX already provides, so it can catch mismatched braces or unrecognized control sequences as you (mis-)type them. It is kind of like what I think flymake is like (I have never actually used flymake, so I don't know for sure). Finally, it has some fancy features which depend on Active-DVI (advi) like mouse-editing of LaTeX documents, such as dragging a control to size an hbox. Neat, but not often used.

Advi is like xdvi on steroids. It is a viewer as well as a document style for making snazzy presentations. Seriously, check out some of the stuff on the site. It can embed videos, launch external applications, and even embed those applications in the same window as the presentation, so you could potentially run Emacs within a dvi or even run advi within itself recursively! The possibilities are endless.

Unfortunately I have not had to make a presentation any time within the last couple years, so it is unlikely I will get to take advantage of all of that sweetness, but it is cool to know it's there.

My only gripe so far is that WhizzyTeX necessarily opens a new window for the preview. I have the screen real-estate, but it would be nice not to have to leave Emacs for anything (soon I'll have email in there as well). I did some searching for the possibility of embedding an X11 application within an emacs buffer (like how it displays pictures, but again on some fat 'roids). That way I could have advi sitting in an Emacs buffer and put that in a separate window from the source and have all of that wonderful interaction. I did some searching but was unable to find anything suggesting that this is possible. If anyone knows anything about it, please let me know. My X11 hacking skills are insufficient to just do it myself, so that's out.

Anyway, I'm off to TA CS31. Get more sleep than I did this week!