SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2009-06-18 22:02:31

chombee
New Member
Registered: 2009-06-18
Posts: 2

Recursive dmenu

Hey,

so dmenu is pretty cool but it does have a limitation compared to other launchers such as Enso, Gnome Do, Quicksilver, etc. etc. You can only do one thing with one hot key.

For example if I bind the usual dmenu script (the one for launching a program from your path) to my Caps Lock key then all I can do from my Caps Lock key is launch a program. I can write dmenu scripts for all kinds of things: selecting a file from my homedir and opening it, doing a google search, looking something up in a dictionary, anything I want really. But I would need a different key bind for each dmenu script.

In Enso (and other launchers) it is different. You summon Enso, select your command (e.g. Open, Define, Google), then select your input to that command (a file or program to open, a word to look up, a term to search for). There's an extra step in there that allows you to run many different Enso commands from a single hot key.

So I wanted to do this with dmenu. My idea is:

1. Create a ~/dmenu_scripts directory where you keep all your different dmenu scripts for doing different things, as many of them as you want.
2. Outside of this directory (e.g. in your normal ~/scripts dir) create this dmenu-bind.sh script:

#!/bin/sh
~/dmenu_scripts/`ls ~/dmenu_scripts | dmenu -nb '#a5b474' -sb '#444444' -nf '#eeeeee' -sf '#a5b474' -fn '-*-*-*-*-*-*-20-*-*-*-*-*-*-*'`

What that does is list all of your scripts from ~/dmenu_scripts in dmenu and execute the one that you select. Bind this script to a key (I like to use Caps Lock).

So lets say you have dmenu scripts 'run', 'open', 'edit', 'define' and 'google' to do various things. You press Caps Lock (or whatever your keybind is) and dmenu pops up listing "run open edit define google" and anything else you have in dmenu scripts. You select 'run'. dmenu immediately pops up again this time listing all the programs on your path. This is the ~/dmenu_scripts/run script now. You select a program and it gets executed. We are using one dmenu script to select and then execute another dmenu script. Get it?

Here's my attempt at a few useful scripts for ~/dmenu_scripts, but no doubt these could be better because I'm not much of a shell scripter. Post your own!

Define something with gnome-dictionary (filename 'define'):

#!/bin/sh
gnome-dictionary --look-up `dmenu -nb '#a5b474' -sb '#444444' -nf '#eeeeee' -sf '#a5b474' -fn '-*-*-*-*-*-*-20-*-*-*-*-*-*-*'`

Open a file from your homedir with gedit (filename 'gedit'):

#!/bin/sh
gedit `ls | dmenu -nb '#a5b474' -sb '#444444' -nf '#eeeeee' -sf '#a5b474' -fn '-*-*-*-*-*-*-20-*-*-*-*-*-*-*'`

Google something with firefox (filename 'google'):

#!/bin/sh
firefox -new-window http://www.google.co.uk/search?q="`dmenu -nb '#a5b474' -sb '#444444' -nf '#eeeeee' -sf '#a5b474' -fn '-*-*-*-*-*-*-20-*-*-*-*-*-*-*'`"

Open something (file, folder, URL) from your homedir with gnome-open (filename 'open'):

#!/bin/sh
gnome-open `ls | dmenu -nb '#a5b474' -sb '#444444' -nf '#eeeeee' -sf '#a5b474' -fn '-*-*-*-*-*-*-20-*-*-*-*-*-*-*'`

Run a command from your path (filename 'run'):

#!/bin/sh
`dmenu_path | dmenu -nb '#a5b474' -sb '#444444' -nf '#eeeeee' -sf '#a5b474' -fn '-*-*-*-*-*-*-20-*-*-*-*-*-*-*'` && eval "exec $exe"

I also have a slightly more complex one called 'markdown' that lets you select a file from your homedir, runs the file through the program markdown, and shows you the result in your web browser.

Offline

Be excellent to each other!

#2 2009-06-19 17:30:10

chombee
New Member
Registered: 2009-06-18
Posts: 2

Re: Recursive dmenu

Here' a minor update to the 'define' and 'google' dmenu scripts. With the define and google commands in Enso there are two possible workflows, you can either type the word you want to look up into Enso after selecting the Enso define command or you can select the word first in another application and then summon Enso and choose define. These define and google dmenu scripts implement that also, the program xclip is used to pipe the current X selection into dmenu as the single item. To select it press return, or if you want to look up something else just type in what you want and press return.

Spellcheck could be done in the same way, given a spellchecker app to launch.

I also realised that  the dmenu command (with the arguments for the colours and font) should be placed in its own file not repeated in lots of files. I'll sort that out at some point.

#!/bin/sh
gnome-dictionary --look-up `xclip -o -selecton primary | dmenu -nb '#a5b474' -sb '#444444' -nf '#eeeeee' -sf '#a5b474' -fn '-*-*-*-*-*-*-20-*-*-*-*-*-*-*'`
#!/bin/sh
firefox -new-window http://www.google.co.uk/search?q="`xclip -o -selecton primary | dmenu -nb '#a5b474' -sb '#444444' -nf '#eeeeee' -sf '#a5b474' -fn '-*-*-*-*-*-*-20-*-*-*-*-*-*-*'`"

Other things I'd like to see working:

* The open command should be better. It should be able to open a file or folder, any URL, or an application.
* A learn_as_open command similar to the Enso one.
* An open with command similar to the Enso one: summon dmenu and select 'open with', from the next dmenu select the thing you want to open, from a third dmenu select the program you want to open it with.
* The google and define commands keeping a history and presenting it through dmenu.
* Commands for manipulating windows like Enso has: go, minimise, maximise, umaximise, close, quit.
* Commands for posting to web services like identi.ca or a pastebin

Offline

#3 2010-07-31 18:14:32

bastiano
#! CrunchBanger
From: Sweden
Registered: 2010-06-01
Posts: 106

Re: Recursive dmenu

I like this, Enso, Aza and Jef Raskin. Are you still working with this idea?

Offline

#4 2013-04-13 16:08:16

Eduardo Mercovich
#! Member
From: Buenos Aires, Argentina
Registered: 2012-10-21
Posts: 59
Website

Re: Recursive dmenu

bump...

Hi chombee, are you still on this?
We are talking about it in http://crunchbang.org/forums/viewtopic.php?pid=301854.


e

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo