Using dmenu in Devuan

This document describes the usage of dmenu based on questions what, how and why.

What?

dmenu is a lightweight, keyboard-centric menu program from Suckless.org that makes running programs lightning fast for the touch typist. For the touch typist, dmenu is much faster than the system menu, even if one uses the keyboard to operate the system menu.

dmenu starts with a cached list of all runnable programs from $PATH. The list is sorted alphabetically, with programs starting with the sequence you typed sorting to the top, and programs containing that sequence below.. Then, as you type characters, it eliminates programs not containing the sequence of characters you typed. So for instance,

How?

Here's how to install and use dmenu:

Install dmenu

  1. apt-get install dmenu Perform this command as root. This command installed dmenu.
  2. dmenu_run Perform this command as a normal user. If the command worked correctly, across the very top of your screen you'll see a thin black stripe with tiny dark gray print, suitable only for folks with 20/10 vision. Don't worry, we'll soon change that during customization. Press the Escape key to get rid of the thin black stripe. Do not press Enter: Doing so would run a random program, which might be destructive.
  3. If you get the top stripe as described in the preceding step, you've successfully installed dmenu. Otherwise, troubleshoot.

Customize dmenu

dmenu is perfectly functional as installed, as long as you have spectacular vision and are able to quickly search that little top stripe. Most people, however, want bigger letters with more contrast, and they want the menu to go down the page, not across the top. This subsection guides you in making a separate shellscript to do exactly that...

  1. su - to become root.
  2. cd /usr/local/bin
  3. Observe and copy to clipboard the following cmd:
    #/bin/sh
    dmenu_run -fn 10x20 \
     -nf yellow -nb black \
     -sf black -sb white \
     -l 20
    
  4. cat > dmenu_mine
  5. Paste the material you copied 2 steps ago.
  6. Press Ctrl+D to get back to the command prompt.
  7. chmod a+x dmenu_mine
  8. dmenu_mine
  9. Look at the screen. It should look like the following, with the top part being large yellow program names on a black background, and the very first program name (which might just be a left square bracket) being black print on white background:
    dmenu screenshot
  10. If the screen doesn't look like the preceding image, troubleshoot based on the steps of these instructions. Pay particular attention to the spacing of arguments in dmenu_mine. The 10x20, 20 and the colors should be preceded by a space. -l20 is wrong and will malfunction: The correct argument is -l 20.
  11. If you'd like to customize your dmenu look, do so by modifying dmenu_mine. If you want a smaller or bigger, try 6x12, 7x14, 8x16, 12x24 as the value for -fn. You might want to change the value of -l to cover more or less of the screen with the menu, or you might want to change the colors.

Setting a hotkey for dmenu

If you had to type dmenu_mine for every program you wanted to run, dmenu would be useless. It's only when you associate a quick and easy hotkey, easily available from the touch-typist's home position, that dmenu assumes its true power.

Different window managers and desktop environments have different ways of associating hotkeys with executable programs like dmenu_run. This document describes how to set Ctrl+Shift+space as the hotkey for dmenu_mine for LXDE and for Devuan's default desktop environment, Xfce.

Xfce

  1. Click Application_Menu->Settings->Keyboard
  2. Click Applications_Shortcuts tab
  3. Click the Add button
  4. Type in /usr/local/bin/umenu_mine
  5. Click the OK button, THEN STOP!
  6. Observe the next dialog box is called "Command Shortcut" and has only a cancel button. This is as it should be. It's asking you to press a hotkey.
  7. Press the Ctrl and Shift keys, and then with the other hand tap the spacebar. The dialog box goes away, and you've just input the hotkey.
  8. To test, press Ctrl+Shift+space. You should get your modified dmenu.

LXDE

There's no completely GUI point and click method to set hotkeys within LXDE. It requires some file editing. These instructions assume you use gvim. If you use emacs or joe or nano, just substitute the appropriate editor command. Here's how you do it:

  1. gvim ~/.config/openbox/lxde-rc.xml Do this as the normal user.
  2. Add the following to the <Keyboard>> node, hopefully in the section defining application hotkeys:
    <keybind key="S-C-space">
      <action name="Execute">
        <command>dmenu_mine</command>
      </action>
    </keybind>
    
  3. Save and quit.
  4. obconf
  5. Desktops_tab, add one to the number of desktops, then subtract one again, then click the Close button. This forces an Openbox reconfigure.
  6. Press Ctrl+Shift+space. This should bring up dmenu, with the appearance specified in /usr/local/bin/umenu_mine. If not, troubleshoot.

Openbox

Follow the directions for LXDE, except instead of editing ~/.config/openbox/lxde-rc.xml, edit ~/.config/openbox/rc.xml.

Tips on efficient use of dmenu

Nominally, the way you use dmenu is to press the dmenu hotkey (Ctrl+Shift+space in our example), enter the first few keystrokes of the program name, and press Enter. But what if...

Many times you need to add arguments to programs on the path. For instance, perhaps you always like to open gvim with three windows, so you normally type gvim -o3 on the command line. So what you might do is make a shellscript called gv3, on the path, that does nothing but gvim -o3. Now you run dmenu and just type gve<Enter>.

Perhaps you occasionally need your program to prompt you for arguments. You can use a shellscript to do that too, although it's beyond the scope of this document.

dmenu saves countless keystrokes, and therefore time. But sometimes there are so many similar programs with identical starting letters that dmenu would be slower than reaching for the mouse. For instance, if you often use xfce4-settings-manager, to get it down to a single entry on which to press Enter, you'd need to enter the following keystrokes: xfce4-settings-m. Less keystrokes wouldn't distinquish it from xfce4-settings-editor. From an efficiency standpoint, this is an abomination.

No problem. Create a shellscript, on the path, called xfmg. Now you just run dmenu and type in xfmg<Enter>. This is quicker than the time it takes to reach for the mouse, let alone navigate the mouse and return to home position.

dmenu is an option, not a way of life

Installing and using dmenu does not in any way limit your ability to use tools you're already using, such as your window manager's system menu, the window manager's GUI run box, nor the Command Line Interface. If your right hand were already on the mouse, you'd click on the window manager's system menu, rather than returning to keyboard home position to use dmenu. dmenu is one more tool you can use to make life easier and faster.

Installing dmenu will not in any way put your existing computer setup in jeopardy. It has very few dependencies. Nothing you use regularly would be deleted or changed by installing dmenu. There's absolutely no cost to installing dmenu, and it just might turbocharge your computer productivity.

Why?

Why use dmenu? Truth be told, not everybody should. The hunt-and-peck, 10 word per minute typist should use the mouse, because dmenu is 100% keyboard centric. The person prioritizing "new" or "pretty" over productivity won't use dmenu. It looks like a user interface from 30 years ago, and it's ugly.

But it's lightning fast in the hands of a touch typist. In less time than it takes to position his hand on the mouse, the touch typist can type Ctrl+Shift+space and libr<Enter>, and be running Libreoffice. Ctrl+Shift+space and icew<Enter> has you running Iceweasel.

For those of us using a user interface without a panel, a user interface like Openbox, Blackbox, Fluxbox, twm and the like, dmenu is even more important. Often, the likelihood of finding a blank spot on the desktop to click is bleak. But always, the likelihood of pressing Ctrl+Shift+space (or whatever other hotkey you decide to assign to dmenu) is 100%, and it's a fast operation.

If you're anything like me, the more you use dmenu, the more you love it.