This page looks best with JavaScript enabled

dmenu - the lightweight, efficient app launcher

 ·  ☕ 4 min read

Background

dmenu is a dynamic menu for X, originally designed for dwm. It manages large numbers of user-defined menu items efficiently. - http://tools.suckless.org/dmenu/. Simply put, dmenu is an extremely lightweight, text based application launcher. If you are familiar with gnome-do, launchy or the standard run dialog (alt+f2), dmenu provides similar functionality with less of a footprint. For a screenshot of dmenu in action see here. dmenu is a small script that, when ran, displays a thin list of applications across the screen. You can type or arrow to the item you wish to launch and press enter to launch the application. I realize dmenu may not be for everyone but it is unique (and well suited for me/a minimalist) in two ways:

  • lightweight - dmenu is not a background process, rather it is available (started) when you invoke/need it so it takes no resources unless you need it
  • simple - dmenu is simple yet flexible, it is command line based, very quick, and very flexible

dmenu allows you to launch commands quickly by invoking dmenu and simply typing a few characters. For example, if I want to start firefox I simply hit SUP+Space (see keybinding section for more info on shortcut key), type fir and hit enter. That is it, firefox will start as normal. A few more examples:

  • launch skype: SUP+Space followed by: skype
  • launch synaptic with sudo privileges: SUP+Space followed by: gksu synaptic
  • launch thunar, starting in your home/bin directory: SUP+Space followed by: thunar /home/drad/bin

Details

Starting dmenu Quickly

dmenu needs to be started each time you wish to use it and while you can simply run “dmenu_run” from a terminal, the run dialog, or any other app launcher this kind of defeats the purpose of dmenu. Most users want a shortcut key to start dmenu quickly and then use dmenu to start the application you are looking for. There are several ways to do this, all dependent upon your desktop manager. I typically run xfce or openbox so I’ll provide a method for creating a shortcut key for each:

XFCE - open the Settings Manager (Menu>Settings>Settings Manager) and go to the Keyboard settings item. In the Keyboard settings dialog, select the Application Shortcuts tab and do the following:

  • click the add button to add a new shortcut
  • in the command box, enter "dmenu_run" (no double quotes) and click ok
  • next the command shortcut dialog will appear, hold the Super (Windows) Key down and press the Spacebar

OpenBox

  • open your rc.xml file in a text editor and add a new keybind element such as follows (see below)
  • restart openbox

Example rc.xml entry for dmenu:

1
2
3
4
5
6
7
8
9
    <keybind key="W-space">
      <action name="Execute">
        <startupnotify>
          <enabled>true</enabled>
          <name>dmenu</name>
        </startupnotify>
        <command>~/.config/dmenu/dmenu-bind.sh</command>
      </action>
    </keybind>

You are all set, now when you press Super + Spacebar dmenu will be started

Installation

dmenu can be installed through most package managers; however, I’ve notices some differences depending on the distribution/version/repo. Generally if you search for dmenu you should find it in suckless-tools along with a few other small/useful apps. Simply install suckless-tools and you will get dmenu. I’ve also notices dmenu in the i3 or dwm packages, so long as you get dmenu and dmenu_run you should be ok. Another option is to get it from the maintainer, suckless.org.

Customize dmenu Look

dmenu’s background, foreground, font, color can all be customized to your liking. See the dmenu man page for all of the options. I’ve also provided my customization below as an example:

  • dmenu_run -p drad$ -nb &#39;#000000&#39; -nf &#39;#FFFFFF&#39; -sb &#39;#848484&#39; -sf &#39;#000000&#39;

An example of dmenu with the above customization (you may want to zoom in - dmenu is the thin bar at the top of the screen):

example of custom dmenu launcher

Fix dmenu Dual Open Issue

There is an issue with dmenu (at least my instances) where dmenu will open after closing an app launched with dmenu. For instance, use dmenu to open feh, feh opens as normal, use feh, upon exit of feh dmenu is opened again (automatically). This is rather odd and confusing as if you are not looking for dmenu to be open it appears your session is froze (mouse clicks don’t work, cannot type into anything other than dmenu box, etc.). This appears to be a known issue in how dmenu is launched. The fix I found is simple and as follows:

  • modify your dmenu-bind.sh script (usually located in ~/.config/dmenu/dmenu-bind.sh) to execute dmenu as follows (note: I have commented out the original line to provide a reference):
1
2
3
4
5
#!/bin/bash

#exe=`dmenu_run | dmenu -nb &#39;#000000&#39; -nf &#39;#d8d8d8&#39; -sb &#39;#d8d8d8&#39; -sf &#39;#000000&#39;` &amp;&amp; eval &quot;exec $exe&quot;

exe=`dmenu_run -nb &#39;#000000&#39; -nf &#39;#d8d8d8&#39; -sb &#39;#d8d8d8&#39; -sf &#39;#000000&#39;` &amp;&amp; eval &quot;exec $exe&quot;</pre></li>

Now dmenu should behave normally upon launching and exiting applications.

Notes

The following links provide more info on dmenu:

Share on

drad
WRITTEN BY
drad
Sr. Consultant