On Aug 13, 2009, at 10:05 AM, Julien Steinhauser wrote:
Julien Steinhauser a écrit :
IMO very bad idea. If you do that you won't be able to run command
with arguments (eg. urxvt -e irssi).
Regards,
Slawek.
You're right, but dmenu is small enough to have several version in /
usr/local/bin.
At the moment, I've one with Fresch patch for vertical display and
xmms like matching,
for mpd playlist and uzbl history and bookmarks, one brand new with
autoconfirmation
to surf in my directories faster than in shell and launching
personnal scripts
which don't need arguments, and a little script to launch terminal
apps direct from dmenu,
which is a copy of dmenu_run in which I've added urxvtc -e beetween
"exec" and "$exe".
Actually, you're not really right, when I tried my new dmenu
yesterday,
it had :
1) the patch to autoconfirm when only one item remains
AND
2) the patch to make it auto confirm on exact matching,
that I had found yesterday and just tested before I post my first
message.
With the second one, it was obviously not possible to give dmenu an
argument.
Now the second one is removed, I just keep going with the proposal
below
that Donald Chai made to me, which works great!
I'm glad it works well for you, this minor change should work for
matching on substrings as well:
diff -r 9b203c5c180d dmenu.c
--- a/dmenu.c Sat Apr 18 12:50:12 2009 +0100
+++ b/dmenu.c Thu Aug 13 11:24:18 2009 -0700
@@ -69,6 +69,7 @@
/* variables */
static char *maxname = NULL;
static char *prompt = NULL;
+static Bool autoconfirm = False;
static char text[4096];
static int cmdw = 0;
static int promptw = 0;
@@ -514,6 +515,12 @@
}
curr = prev = next = sel = item;
calcoffsets();
+
+ if(autoconfirm && item && !item->right) {
+ fprintf(stdout, "%s", item->text);
+ fflush(stdout);
+ running = False;
+ }
}
void
@@ -674,6 +681,8 @@
fstrncmp = strncasecmp;
fstrstr = cistrstr;
}
+ else if(!strcmp(argv[i], "-a"))
+ autoconfirm = True;
else if(!strcmp(argv[i], "-b"))
topbar = False;
else if(!strcmp(argv[i], "-fn")) {
To all people who have complained about such patch,
as it could break their personnal scripts
or complicate their life in making impossible
adding arguments to dmenu,
I guess you have done a confusion beetween "exact match
autoconfirmation",
which wasn't actually my request and "one remaining item
autoconfirmation"
With Donald's proposal, I can still give arguments to dmenu
and none of my scripts are broken.
I think the argument against this patch is the following situation:
I run
echo -e "opera\nxpdf" | dmenu -a
if I want to type "xpdf foo.pdf" to open foo.pdf, I can't. dmenu will
immediately output "xpdf" after I press 'x'.
To any detractors:
1) Please stop telling people what to do with their own computer.
2) I personally use dmenu only with a static list of X apps (a listing
of command-line apps from /bin is just clutter), so Julien's idea
works great for me, as the behavior is totally predictable.
3) We had a discussion on the list about program arguments, and the
conclusion was that bashrun is probably better suited for this case.
#!/bin/sh
cd /
index=`ls -dU .*/ */ | dmenu -p $PWD`
[ -z $index ]
if [ $? = 1 ]; then
cd $index && lsd ; else
actions
fi
FYI: I don't know if this is representative of your shell code, but
you can simplify it by using
if [[ -n $index ]]; then
or
if [[ "x$index" != "x" ]]; then