[2025-jun-17] The SlackDocs Wiki has moved to a new server, in order to make it more performant.
Table of Contents
dmenu
dmenu is a dynamic menu for X, originally designed for the suckless project. It is most commonly used as a lightweight application launcher in tiling window managers such as dwm, but it can also read arbitrary input from standard input, making it useful for any “pick one item from a list” task in shell scripts.
Installation
From SlackBuilds
- Slackware 15.0: https://slackbuilds.org/repository/15.0/desktop/dmenu/
- SlackBuilds Overlay: https://git.sr.ht/~r1w1s1/slackbuilds-overlay/tree/main/item/desktop/dmenu
From source
git clone https://git.suckless.org/dmenu cd dmenu make sudo make install
Basic Usage
Launch dmenu with the default dmenu_run wrapper, which lists all executables in $PATH:
dmenu_run
In dwm, the default keybinding to launch dmenu_run is Alt + p.
Configuration
Like other suckless tools, dmenu is configured by editing config.h and recompiling. Configuration details, common patches, and customization examples will be covered in a future revision of this page.
dmenu as an Application Menu
dmenu is not limited to launching executables from $PATH. By piping a custom list into it, you can build an interactive application menu — similar to a desktop environment's app launcher.
The script below maps named entries to commands, mixing GUI apps, terminal apps, and system commands in a single menu:
#!/bin/sh # Wrap a command in a terminal # Replace 'st' with your terminal emulator (xterm, alacritty, urxvt...) term() { st -t "$1" -e "${@:2}" } choice=$(printf "%s\n" \ "Browser" \ "Terminal" \ "IRC" \ "Mail" \ "PDF" \ "Editor" \ "Files" \ "Mixer" \ "WiFi" \ "Bluetooth" \ "Reboot" \ "Shutdown" | dmenu -i -l 12 -p "Menu" \ -fn "Monospace-11" \ -nb '#000000' -nf '#ffffff' \ -sb '#005f87' -sf '#ffffff') case "$choice" in # Browser: firefox, chromium, librewolf... Browser) firefox ;; # Terminal: st, xterm, alacritty, urxvt... Terminal) st ;; # IRC: senpai, irssi, weechat... IRC) term IRC senpai ;; # Mail: mutt, neomutt, thunderbird... Mail) term Mail mutt ;; # PDF: zathura, mupdf, evince... PDF) zathura ;; # Editor: vim, geany, kate, micro... Editor) geany ;; # Files: ranger, noice, nnn, thunar... Files) term Files noice ;; # Mixer: pavucontrol, alsamixer... Mixer) pavucontrol ;; # WiFi: nmtui, wifitui... WiFi) term WiFi nmtui ;; Bluetooth) blueman-manager ;; Reboot) sudo /sbin/reboot ;; Shutdown) sudo /sbin/poweroff ;; esac
The -l flag displays entries as a vertical list, -p sets the prompt label, and -i makes matching case-insensitive.
Binding a Hotkey
To launch the menu with a keyboard shortcut, add an entry to your hotkey daemon. Example using sxhkd (~/.config/sxhkd/sxhkdrc):
# Menu
super + space
$HOME/.bin/menu
Replace $HOME with the full path if your shell does not expand it, e.g. /home/username/.bin/menu.
If you use dwm, you can bind it directly in config.h without any extra daemon — the default keybinding for dmenu_run is Mod + p:
{ MODKEY, XK_space, spawn, SHCMD("$HOME/.bin/menu") },
See Also
- dwm config.h Quick Reference — covers how dwm passes color variables to dmenu via
dmenucmd[]
Sources
- Originally written by r1w1s1