A new building block of my environment: dmenu

January 4, 2011

Nick Coleman's comment on my last tools entry introduced me on to dmenu, which has rapidly become an important component of my environment. The basics of dmenu are described nicely in Nick's comment, but I do two unconventional things with it.

The first is that I drastically restrict dmenu's command completion. The 'standard' dmenu setup has it doing command completion on everything in your $PATH. After trying this briefly, I rapidly came to the conclusion that it made no sense and only created clutter. There's only a few X programs that I run frequently (and most of the things on my $PATH need to be run in a terminal anyways), and it is much simpler and less cluttered to list them explicitly. Explicitly controlling dmenu's command completion also lets me list my most frequent program first, so that it takes two keystrokes to start it (dmenu starts with the first entry in the command list selected).

The main unconventional thing I do is that I use dmenu not so much to run commands but to provide abbreviations for things that I do very frequently. Some of these things are themselves commands, such as my test Firefox environment. Some of these things are done by small helper scripts, such as a script that uses Firefox remote control to run a Google search on its command line arguments; a similar script runs a search on our internal system documentation.

(These helper scripts have deliberately short names, usually single letters, and so are not in my normal $PATH. My dmenu frontend adds their directory, actually several directories, to $PATH.)

But a lot of the things I do a lot don't fit in the command model, so I handle them directly with heuristics in the driver script. Some examples:

  • if I type the name of an internal machine, I want to run an sshterm to it.
  • '@<machine name>' means a root sshterm to that machine
  • the name of an external machine or anything matching *.*/* is taken as a URL and handed to Firefox through remote control.
  • I have brief abbreviations for a number of websites that I visit frequently (mechanically these are implemented as little scripts using Firefox remote control on fixed urls).

The result of all of this hackery works extremely well for me. Although I only started using dmenu a few months ago, it has already become an essential and reflexive part of my desktop environment and it's well on the way to supplanting various previously heavily used parts of my environment, to some extent including pyhosts itself.

(This is all the more startling to me because my desktop environment tends to change only slowly and rarely. Rapid revolutions are quite rare, although not unknown; sometimes when I fall in love with things I really fall in love with them.)


Comments on this page:

From 94.79.136.60 at 2012-09-23 17:27:00:

This is a really good idea. I previously had several dmenu scripts each for different things and invoked with different keys but combining them seems to work well. So for example, in addition to using @ for hosts, I prefix everything from the path with an =.

You're right about the path being fairly useless due to being mostly full of terminal-based programs. Parsing /usr/share/applications/*.desktop is actually quite useful because you don't have to maintain it manually.

Written on 04 January 2011.
« On improved but less functional versions of things
An actual use for the CSS overflow property »

Page tools: View Source, View Normal.
Search:
Login: Password:

Last modified: Tue Jan 4 01:23:18 2011
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.