Programing, Hacking, and the likes

Stumpwm and Cmus (or Any Other Terminal Program)

| Comments

Update 2nd September 2011: It seems I forgot to write how to configure gnome-terminal to keep the original title. In Profile Preferences go to Title and Command and set When terminal commands set their own titles to Prepend initial title.

Stumpwm is an excellent tiling window manager written entirely in Common Lisp. It is fully keyboard driven and hackable to the fullest. The wm is running in it’s own CLisp REPL, so you can connect with Slime+Emacs and hack directly. It is super easy to customize the wm, simply re-evaluate and you are good to go!

cmus is an equally awesome program I enjoy using, a very efficient music player that runs in a terminal emulator.

I wanted to have a keybinding either bringing cmus in focus, or starting it if it isn’t running. As cmus is running in a terminal emulator, it wasn’t straight forward how to achieve this. I am using the Gnome Terminal, so this solution will have to be modified to work with other terminals. Of course, the code is added to the .stumpwm file, but you could also just evaluate it to try it out.

(defcommand cmus () ()
  "Run or switch to CMus"
  (run-or-raise "gnome-terminal -e cmus -t cmus"
(:instance "gnome-terminal" :title "cmus")))

Now I just have to bind the command to an appropriate key

(define-key *root-map* (kbd "C-p") "cmus")

This works because I set the title of the terminal when I launch it. cmus changes the title based on what song is playing, so it will not work without doing this.