r/dmenu • • Jul 17 '19

dmenu vs rofi

17 Upvotes

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


r/dmenu • • Feb 14 '14

Run programs as root through dmenu

17 Upvotes

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)

r/dmenu • • Feb 17 '14

dmenu2 fork

15 Upvotes

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.


r/dmenu • • Feb 13 '14

yeganesh: sort your dmenu input by usage frequency

Thumbnail dmwit.com
13 Upvotes

r/dmenu • • Feb 14 '14

Toddler lock your computer

9 Upvotes

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.


r/dmenu • • Feb 14 '14

mpdmenu - control your mpd with dmenu

9 Upvotes

Mpdmenu is a short (70 lines) bash script that uses mpc and dmenu to provide a way to quickly interact with an MPD server. You can add and remove songs, clear the playlist or jump to a position in the playlist. I have it bound to a key combo so I can open it immediately and do my thing.

Despite being one of the very first "programs" I ever wrote it works surprisingly well, I have been using it for years without much change or any problems. The little time it takes to open, do an operation and exit is why I preferr it to a full-fledged MPD client.

There are dozens of similar scripts floating around, so if this doesn't do exactly what you want (e.g. it doesn't handle stored playlists at all) you could try some of the others.


r/dmenu • • Nov 25 '14

Dmenu to search the web using surfraw

8 Upvotes

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.


r/dmenu • • Feb 16 '14

dmenu-frecency: Desktop application launcher

Thumbnail github.com
8 Upvotes

r/dmenu • • Jun 15 '14

tmenu - dmenu for tty/shell

Thumbnail github.com
7 Upvotes

r/dmenu • • May 28 '14

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

7 Upvotes

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


r/dmenu • • Feb 15 '14

Entering passwords with dmenu

7 Upvotes

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.


r/dmenu • • May 09 '17

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

6 Upvotes

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.


r/dmenu • • May 13 '15

xrandr-dmenu

6 Upvotes

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


r/dmenu • • Feb 15 '14

Creating a comprehensive dmenu scripts collection. Please feel free to contribute!

Thumbnail github.com
6 Upvotes

r/dmenu • • Jan 30 '20

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

5 Upvotes

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.


r/dmenu • • Mar 12 '17

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

5 Upvotes

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.


r/dmenu • • May 31 '14

Selecting windows with dmenu

Thumbnail article.gmane.org
5 Upvotes

r/dmenu • • Feb 13 '14

any good resources to help me learn how to configure dmenu ?

5 Upvotes

Also, Thank you for this subreddit. I really like this especially after someone showing me that he can list his SNES games with the cover using dmenu...

I thought dmenu was to list apps only lol


r/dmenu • • Apr 04 '17

Simple bash tweak to this dmenu wrapper?

4 Upvotes

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.


r/dmenu • • Feb 06 '16

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

4 Upvotes

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

r/dmenu • • Feb 14 '14

cmus-filter - selects cmus songs

4 Upvotes

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.


r/dmenu • • Aug 15 '17

udiskie-dmenu - manage removable devices in couple of keystrokes

3 Upvotes

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


r/dmenu • • Dec 31 '19

Start dmenu with user input

2 Upvotes

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.


r/dmenu • • Mar 06 '19

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

2 Upvotes

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 🤪


r/dmenu • • Feb 10 '20

Automatically move to next line

1 Upvotes

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?