dmenu for everything

18 Nov 2012

I love minimalism systems and programs who focus in doing a single task very well, dmenu is one of them, it reads input from user, matches patterns and returns results, simple! With this functionality it can (ab)used to create launchers for almost anything, let’s review how to create a virtualbox launcher…

The first step (and the hardest) is to figure out how to create an option list to present in screen, on this example vbox machines:

$ vboxmanage list vms | cut -d\" -f2

Once defined, it’s easy to come up with missing parts:

DMENU='dmenu -p > -i -nb #000000 -nf #ffffff -sb #000000 -sf #3B5998'
vboxmachine="$(vboxmanage list vms | cut -d\" -f2 | $DMENU)"
[ -z "${vboxmachine}" ] && exit 0 || vboxmanage -q startvm "$vboxmachine" --type gui

Everything in 3 LOC!, this script can now be saved at /usr/local/bin/ and used as a shortcut, in my use case, I added it to ~/.i3/config:

# vbox:
bindsym $Altgr+v exec dmenu_vbox

So now I can launch vbox machines by pressing Altrg + v and select the appropiated machine, if you liked dmenu as much as I did, I’ve made a handful of scripts to control music, user sessions, apps, etc. Feel free to grab them at: