dmenu

dmenu is a fast and lightweight dynamic menu for X. It reads arbitrary text from stdin, and creates a menu with one item for each line. The user can then select an item, through the arrow keys or typing a part of the name, and the line is printed to stdout. dmenu_run is a wrapper that ships with the dmenu distribution that allows its use as an application launcher.

Installation

Install the dmenu package, or dmenu-gitAUR for the development version.

Various patched variants exist which extend dmenu's default functionality. Consider installing one of the following packages from the AUR:

  • dmenu2AUR: dmenu fork with many useful patches applied and additional capabilities added including dimming, specifying a custom opacity, and underlining.

You may run dmenu with:

$ dmenu_run

Configuration

Now, you will want to attach the dmenu_run command to a keystroke combination. This can be done either via your window manager or desktop environment configuration, or with a program like xbindkeys. See the Hotkeys article for more information.

Displaying custom items

Custom items will be shown by separating them with a new line (\n) and piping them into dmenu. For example:

$ echo -e "first\nsecond\nthird" | dmenu

Manually adding items

dmenu will look for executables in the directories defined in your $PATH. For information on modifying your $PATH see environment variables.

Fonts

dmenu can display fonts using XFT. This example will run dmenu using ttf-droid:

$ dmenu_run -fn 'Droid Sans Mono-9'

Support for shell aliases

dmenu does not support shell aliases. To have dmenu recognize your aliases, install the dmenu-recent-aliases-gitAUR package from the AUR and run . Your aliases must be in to be recognized by dmenu-recent-aliases.

Support for history

To sort commands by recency, download dmenu_run_history to your $PATH and use instead of .

Tips and tricks

Taking input using dmenu

Inside a script (e.g. launched from a shortcut), getting user input is sometimes required. We can use dmenu for this, by passing it an EOF: the selection field will be empty and dmenu can take user input.

Since reading /dev/null will return an EOF, this can simply be done by the following command:

$ dmenu < /dev/null

Troubleshooting

No locale support

Running dmenu_run results in the following error message:

Make sure that the environment variable is correctly set. See the following for more information: Locale#Troubleshooting

Missing menu entries

If certain entries are missing from dmenu, the cache may be malformed. Delete it and restart dmenu.

$ rm ~/.dmenu_cache
$ rm ~/.cache/dmenu_run

Note that there will most likely be only one cache file, depending on if is set. See the contents of for more information.

Environment variables

Environment variables needed for applications should instead be added to .

gollark: I'm going to announce new BGP routes with HTML and 10 monitors to delete that message from Discord and your brain.
gollark: ||r||||e||||a||||l|||| ||||h||||4||||x||||x||||0||||r||||z|||| ||||u||||s||||e|||| ||||s||||p||||o||||i||||l||||e||||r||||s|||| ||||t||||o|||| ||||m||||a||||k||||e|||| ||||s||||u||||r||||e|||| ||||t||||h||||a||||t|||| ||||n||||o||||b||||o||||d||||y|||| ||||e||||l||||s||||e|||| ||||c||||a||||n|||| ||||r||||e||||a||||d|||| ||||t||||h||||e||||i||||r|||| ||||m||||e||||s||||s||||a||||g||||e||||s||
gollark: Stop them! If you backtrace using BGP to access the internet with a virtual data structure you can counterhack with a Raspberry Pi!
gollark: `<hr>` works like `<br>` and doesn't need closing.
gollark: You're getting```html<html><head><title>301 Moved Permanently</title></head><body bgcolor="white"><center><h1>301 Moved Permanently</h1></center><hr><center>nginx</center></body></html>```to a prison far, far away from here...

See also

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.