/r/dmenu

Photograph via snooOG

a subreddit for sharing dmenu hacks and adaptations

dmenu is a dynamic menu for X, originally designed for dwm. It manages large numbers of user-defined menu items efficiently.

dmenu/

patches/

scripts/

/r/dmenu

632 Subscribers

1

Automatically move to next line

I use dmenu for selecting songs to play next, using the mutli select feature (ctrl+return). But the problem is, pressing the ctrl+return once does not move the highlight to the next line. I have to manually press down arrow and go to next line. So, selecting 19 songs means pressing the down arrow twenty times. I was just wondering if there's a workaround for this?

1 Comment
2020/02/10
12:59 UTC

5

Unable to set binding for pasting (another key to Ctrl-Y)

I'm not too familiar with how pasting works in Linux, but I know that when I copy cell contents from LibreOffice, it can only be paste to dmenu via Ctrl-Y (Ctrl-Shift-y). I want to bind Ctrl-v (Ctrl-v) to paste to dmenu like how pasting works traditionally. Seems simple enough, since it's not bound to anything by dmenu so no potential conflicts.

Looking at dmenu.c, I simply copy XK_Y to XK_v (and XK_V for good measure), but the following does not work like I would expect:

--- dmenu-4.9/dmenu.c	2020-01-29 23:35:55.978968100 -0500
+++ dmenu-4.9/dmenu.c	2020-01-30 00:41:13.247510200 -0500
@@ -354,6 +354,14 @@
   			while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]))
			insert(NULL, nextrune(-1) - cursor);
		break;
+		case XK_v:
+			XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY,
+			                  utf8, utf8, win, CurrentTime);
+			return;
+		case XK_V:
+			XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY,
+			                  utf8, utf8, win, CurrentTime);
+			return;
	case XK_y: /* paste selection */
	case XK_Y:
		XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY,

Instead, it simply copies the existing default functionality of C-y and C-Y to C-v and C-V respectively. I'm not sure how XK_v and XK_V are behaving differently despite having the same code.

Any help is much appreciated.

2 Comments
2020/01/30
06:20 UTC

2

Start dmenu with user input

Is there a way to start dmenu with text already in the user input box? If not, is there a way to do it in rofi?

I'm trying to make a script to rename workspaces and I want rofi to show with the current name already typed in.

1 Comment
2019/12/31
07:29 UTC

1

Error compiling dmenu

Hello guys,

I've just taken up using suckless utilities and trying to figure things out. I'm trying to compile dmenu and I'm getting this error:

dmenu build options:
CFLAGS   = -std=c99 -pedantic -Wall -Os -I/usr/X11R6/include -I/usr/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION="4.9" -DXINERAMA
LDFLAGS  = -L/usr/X11R6/lib -lX11 -lXinerama -lfontconfig -lXft
CC       = cc
cc -c -std=c99 -pedantic -Wall -Os -I/usr/X11R6/include -I/usr/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"4.9\" -DXINERAMA dmenu.c
In file included from dmenu.c:11:
/usr/include/X11/Xlib.h:44:10: fatal error: X11/X.h: No such file or directory
   44 | #include <X11/X.h>
      |          ^~~~~~~~~
compilation terminated.
make: *** [Makefile:18: dmenu.o] Error 1

I'm probably missing some Xorg package but am unable to figure it out. I would be glad if someone could help me.

2 Comments
2019/12/21
14:51 UTC

15

dmenu vs rofi

Which is better? Lightweight? Configurable? Ease of use? In the repos? Plugins? Works ootb? Elite only?

9 Comments
2019/07/17
05:45 UTC

1

Problem compiling dmenu in Debian 9

Hello guys. I'm having trouble compiling the dmenu in Debian Stretch. When I run make the output is:

dmenu build options:
CFLAGS   = -std=c99 -pedantic -Wall -Os -I/usr/X11R6/include -I/usr/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION="4.9" -DXINERAMA
LDFLAGS  = -L/usr/X11R6/lib -lX11 -lXinerama -lfontconfig -lXft
CC       = cc
cc -c -std=c99 -pedantic -Wall -Os -I/usr/X11R6/include -I/usr/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"4.9\" -DXINERAMA drw.c
drw.c: In function ‘xfont_create’:
drw.c:143:38: error: ‘FC_COLOR’ undeclared (first use in this function)
  if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
                                      ^~~~~~~~
drw.c:143:38: note: each undeclared identifier is reported only once for each function it appears in
drw.c: In function ‘drw_text’:
drw.c:353:32: error: ‘FC_COLOR’ undeclared (first use in this function)
    FcPatternAddBool(fcpattern, FC_COLOR, FcFalse);
                                ^~~~~~~~
Makefile:18: recipe for target 'drw.o' failed
make: *** [drw.o] Error 1

I have already installed some packages like: libxtst-dev libxinerama-dev libx11-dev. Anyone have any idea what's missing?

0 Comments
2019/04/19
22:15 UTC

2

dmenu shows up but displays no programs or files, doesn't run anything

As the title says, when I run dmenu, the bar comes up - but as I type, no programs or files are shown, and when I type a programs entire name and hit entire, nothing happens. What's going on?

[EDIT] Fixed! Keybind was set to exec dmenu and not dmenu_run 🤪

4 Comments
2019/03/06
23:12 UTC

1

How to delete an unwanted item from dmenu ?

ranger wasn't launching from dmenu so i created a bash script with "xterm ranger" and put it in one of the $PATHs .. now the name of the bash script shows up in dmenu and ranger launches fine, However, there is the unwanted entry "ranger" that shows up everytime I search for ranger. I tried to delete the file ranger.desktop from /usr/share/applications but no luck...What else should I try ?

I am using Ubuntu minimal 18.04 + dwm + dmenu

14 Comments
2019/02/26
04:39 UTC

1

dmenu and ranger

dmenu does not open ranger. I am using urxvt . Thanks

1 Comment
2018/11/15
04:12 UTC

1

[dmenu] non blocking stdin (x-post /r/suckless)

I've applied the non blocking stdin patch to dmenu. It's working fine when I pipe the initial content (like normal dmenu), but I'm not able to get it working when stdin changes.

What I did so far is create an Unix socket with socat and pipe it to dmenu. Then I connect to the socket from another TTY, but dmenu doesn't refresh the available options:

(x11 terminal)$ socat UNIX-LISTEN:/tmp/dmenu_test - | dmenu
(tty)$ ls ~/ | socat UNIX-CONNECT:/tmp/dmenu_test - 

Any idea?

0 Comments
2018/09/13
08:56 UTC

1

[Question] Can you know obfuscate dmenu’s text input?

If I’m using dmenu as my UI-helper for SUDO_ASKPASS, when I input my password it is visibly displayed as plaintext.

Is there any way to obfuscate this in some way, visually?

1 Comment
2018/04/26
05:42 UTC

4

udiskie-dmenu - manage removable devices in couple of keystrokes

Lightweight nodejs script which allows to manage removable devices via dmenu (or rofi). Hopefully it will be useful also to someone else than only to me. https://github.com/fogine/udiskie-dmenu

6 Comments
2017/08/15
22:52 UTC

6

xmenu is a fork of suckless dmenu with open community policy.

suckless dmenu is a decent program, yet it is guarded by hostile people. I wanted to use dmenu as a password prompt, but I had to find a password prompt patch for dmenu on the internet because this small solution to password problem was rejected by suckless people.

I felt that dmenu needed a better competitor so that everyone including me benefits in the long term. Free market competition improves products.

I created a github organization at https://github.com/small-utils to host xmenu, a fork of dmenu.

xmenu is governed by C4(Collective Code Construction Contract). C4 is based on optimistic merging theory. I experienced C4 in zeromq community. I and other zeromq contributors agreed that C4 reduces friction in collaboration.

I hope anyone who is interested in open community takes a look and perhaps submits pull requests.

19 Comments
2017/05/09
07:41 UTC

5

Simple bash tweak to this dmenu wrapper?

Found a todo wrapper (think it was from a poster on this forum) an tweaked it a little. The usage is: create/select todo list, then create/delete todo items for that list. There are some things i want to change about it:

  • Make the script cleaner and actually improve the quality of the code

  • Like someone mentioned, incremental search + exact match is necessary--currently it matches substrings or something along those lines (maybe a limitation of grep?). But I guess I will have to learn more about Bash/Linux to fix this

  • Make it save the todo lists with a .txt extension but show the todo list name without the extension for readability purposes.

The last point seems easily doable for my limited Bash scripting skills but I'm struggling to find the culprit. It seems that after a new todo-list is created (ex. music.txt) with some notes added, if I open that todo-list, it gets saved as music.txt.txt, then music.txt.txt.txt, .etc. What I want is to prompt user for the name of the todo (music), then it saves it as music.txt. Essentially, what the user inputs and sees should never include .txt extension, but internally it is saved as a .txt file to make it clear that it is a text file that can simply be edited.

I know what I'm asking for is mundane and simple but I'm struggling to tweak it. How can I fix this? And any improvements you would suggest to improve the quailty of the code? Any hints or help is much appreciated.

1 Comment
2017/04/04
17:34 UTC

5

Possible to list files from a directory and select to play with mpv?

I typically open up the terminal, cd to my movies directory, do an ls to see which movies are in the directory, and then run mpv on the movie I want to watch.

Is it possible to simplify this process to be more efficient via dmenu? For example, I type "movies" and press TAB or ENTER or something and then dmenu shows all the entries of the files from the movie directory. Then I select an entry and mpv will play it.

I don't have much scripting experience so I'm hoping I can look at examples and tweak it--I suspect what I'm looking for or something close to it is popular and there are already solutions for it. Obviously this function has a variety of uses as well--in general, it simplifies the task of searching and executing files (much less keystrokes) without the need of opening up a terminal.

Much appreciated.

1 Comment
2017/03/12
04:00 UTC

1

Is it possible to configure dmenu to use shell alias settings?

For example, I like to run "feh -d" and have that set as a shell alias (feh='feh -d'). When I launch feh via dmenu it loads the binary and not my alias.

1 Comment
2016/12/13
16:45 UTC

5

Using dmenu to locally search your (google) contacts csv file

Task: Look up some information on a contact.

Using the phone is too slow. Using google contacts is annoying. If you have a local version of your contacts in a CSV file, then this will give you access to the data. It's a hack and you might need to customize it, but it should give you the idea. After the second round of picking what you want, it will be in the clipboard, so you can just paste it where you want it.

csvcut -C "Notes" google.csv | dmenu -i -l 10 | tr , '\n' | sed 's/:::/\n/g' | uniq | grep -v -e '^$' | dmenu -i -l 10 | xsel -i -b

Step 1: export your (google) contacts into a CSV file

Step 2: install csvkit

Step 3: have fun with dmenu

Example use "get the email address":

  • launch script from your favorite WM
  • enter the name until you have them selected and press return
  • enter @ to get all the email addresses
  • select the email you want and press return
  • paste it into the application where you want it
1 Comment
2016/02/06
20:50 UTC

6

xrandr-dmenu

This is a shell script that puts a dmenu interface on xrandr. It still needs a little work, but it is functional. Current dependencies:

  • dmenu
  • sed
  • xrandr
  • zsh

I would love some feedback, both on the user interface and on code improvements. This is the first shell script that I wrote that I tried to stick to the style guides, so while it is substantially better than anything else I have written, it is probably still pretty rough.

https://github.com/JumperPunk/scripts/blob/master/xrandr-dmenu

4 Comments
2015/05/13
18:23 UTC

1

Dmenu itemize anything?

I am using the j4-dmenu with arch so that it lists my .desktop apps. Can I configure regular dmenu to itemize whatever? I now know how to configure the output, how do I configure what it itemizes?

5 Comments
2015/03/07
00:40 UTC

8

Dmenu to search the web using surfraw

sr $(sr -elvi | gawk '{ print $1 }' | dmenu -p search )

provides a dmenu with all of surfraw's configured search options and runs sr with your selected search.

surfraw is a command-line websearch tool.

I use surf but tried experimenting with using, links -source | urlscan, or something like that, to parse the links and pipe the output back to dmenu.

edit: Here's the eventual script using perl and HTML:::LinkExtractor that pipes results back to dmenu:

#!/bin/bash

get_links() {
perl -E ' 
        use HTML::LinkExtractor;
        use Data::Dumper;

        local $/;
        my $input = <STDIN>;
        my $query = $ENV{query};
        #chomp( $input );
        my $LX = new HTML::LinkExtractor();
        $LX->strip(1);

        $LX->parse(\$input);


        my @links = @{$LX->links}; 

        foreach my $link ( @links ){
            $text = $link->{"_TEXT"};
            $href = $link->{"href"};
            if ($href =~ /http/ && ( $text =~ /\Q$query/i || $href =~ /\Q$query/i ) ){
                my $href = $link->{"href"};
                $href =~ s/.*http/http/; 
                print $link->{"_TEXT"}." \t $href\n";
            }
        }
        __END__
    '
}

uastr="Mozilla/5.0 (Windows NT 6.3; WOW64) Chrome/41.0.2226.0 Safari/537.36"
searchstr=$(sr -elvi | gawk '{print $1}' | dmenu)
if [[ -z $searchstr ]]; then
    exit 0
fi
query=$(cut -d " " -f 2 < $searchstr)

#for perl
export query=$query

url="$(sr -browser=echo $searchstr)"
link=$(curl -A "$uastr" "$url" | get_links | dmenu -l 12 | cut -s -f 2)

#nicer to use curl than elinks but it's an option
#link=$(elinks -source "$url" | get_links | dmenu -l 12 | cut -s -f 2)

regex='^[ *]http.*' 

if [[ $link =~ $regex ]]; then
    surf $link
fi

and this one does google, filtering out the useless links...

#!/bin/bash


get_links() {
perl -E ' 
        use HTML::LinkExtractor;
        use Data::Dumper;

        local $/;
        my $input = <STDIN>;
        #chomp( $input );
        my $LX = new HTML::LinkExtractor();
        $LX->strip(1);

        $LX->parse(\$input);


        my @links = @{$LX->links}; 

        foreach my $link ( @links ){
            if (!$link->{"class"} && $link->{"href"} =~ /http/ ){
                my $href = $link->{"href"};
                $href =~ s/.*http/http/; 
                print $link->{"_TEXT"}." \t $href\n";
            }
        }
        __END__
    '
}

uastr='Mozilla/5.0 (Windows NT 6.3; WOW64) Chrome/41.0.2226.0 Safari/537.36'
echo hello

query=$(echo "" | dmenu -p "search google:")
echo hellohey
if [[ -z $query ]]; then
    exit 0;
fi

export query=$query
url="$(sr -browser=echo google -results=50 $query)"
result=$(curl -A "$uastr" "$url" | get_links | dmenu -l 12 | cut -s -f 2)

#link=$(elinks -source "$url" | get_links | dmenu -l 12 | cut -s -f 2)
regex=".*http.*" 

if [[ $link =~ $regex ]]; then
    surf $link
fi

but they're not ideal. I barely use them, and the problem of filtering out the interesting links doesn't yield an obvious blanket solution.

1 Comment
2014/11/25
07:41 UTC

6

dmenu_run.pl that returns weighted results based on usage [x-post from /r/linux]

I got sick of selecting the second or third choice every time I typed a few letters of my most-commonly run apps into dmenu. This script keeps track of which commands you run most often and will always present them first.

I originally posted this script a year ago and today updated it to handle arguments better. It's written in perl with only core modules and I haven't noticed a significant speed hit. It should be a drop-in replacement for dmenu_run.

Code lives here: http://pastebin.com/Xee6eG8f

x-post in /r/linux

original post

0 Comments
2014/05/28
18:01 UTC

13

dmenu2 fork

https://bitbucket.org/melek/dmenu2

Found this a while ago. I don't think it needs its own sub but I figured some of you would be interested.

This fork has many of the patches I like built in. It also does transparency if you're into that kind of thing.

1 Comment
2014/02/17
16:28 UTC

7

Entering passwords with dmenu

In the (password manager I wrote)[https://github.com/pavpanchekha/dotfiles/blob/master/bin/run], I use dmenu to enter passwords by reading in black-on-black text.

1 Comment
2014/02/15
06:40 UTC

14

Run programs as root through dmenu

First, we create a dmenu-based prompt to serve as an askpass helper for sudo.

Let's call this script dpass:

#!/bin/bash
dmenu -p "$1" <&- && echo

Edit the colors to your preference, stick it somewhere, set the +x bit, and we're done.

Now, when we want to run something as root through dmenu, we can use the sudo switch -A, along with the SUDO_ASKPASS environment variable, to pull up the usual dmenu list, choose something to run, then get a root password prompt. For example :

SUDO_ASKPASS=/path/to/dpass sudo -A $(dmenu_path | dmenu)
1 Comment
2014/02/14
23:05 UTC

7

Toddler lock your computer

https://github.com/sagotsky/.dotfiles/blob/master/scripts/toddler.sh

This dmenu script is simple but I wanted to share it because it's novel and I felt really clever when I figured it out (but that could have just been the coffee kicking in). My son has figured out that the keyboard (fixed) is the most useful piece of my computer. Sometimes I want to lock it from him. Throwing up an endless series of dmenu until a magic word is typed does the job.

4 Comments
2014/02/14
20:38 UTC

4

cmus-filter - selects cmus songs

https://github.com/sagotsky/.dotfiles/blob/master/scripts/cmus-filter.sh

Requires docopt and (obviously) cmus.

Assuming you have a well structured music directory, this lets you control cmus live filters by dmenu. What's neat (and was fun to script) is that you can select things at the song, album, artist, or whatever level, provided your collection is structured nicely. In xmonad I have bindings for choosing a song, choosing an album, and playing a random album.

1 Comment
2014/02/14
20:27 UTC

Back To Top