[hackers] [dmenu] faster dmenu_run -f || Connor Lane Smith
changeset: 465:a01bf6957bb4
tag: tip
parent: 463:39c6c58ca2ff
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Sat Nov 19 21:24:07 2011 +0100
files: dmenu.c dmenu_run
description:
faster dmenu_run -f
diff -r 39c6c58ca2ff -r a01bf6957bb4 dmenu.c
--- a/dmenu.c Wed Nov 16 11:26:15 2011 +0100
+++ b/dmenu.c Sat Nov 19 21:24:07 2011 +0100
_AT_@ -117,7 +117,7 @@
setup();
run();
- return EXIT_FAILURE; /* unreachable */
+ return 1; /* unreachable */
}
void
diff -r 39c6c58ca2ff -r a01bf6957bb4 dmenu_run
--- a/dmenu_run Wed Nov 16 11:26:15 2011 +0100
+++ b/dmenu_run Sat Nov 19 21:24:07 2011 +0100
_AT_@ -1,12 +1,15 @@
#!/bin/sh
-CACHE=${XDG_CACHE_HOME:-"$HOME/.cache"}/dmenu_run
-if [ ! -d "`dirname "$CACHE"`" ]; then
- CACHE=$HOME/.dmenu_cache
+cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
+if [ -d "$cachedir" ]; then
+ cache=$cachedir/dmenu_run
+else
+ cache=$HOME/.dmenu_cache
fi
(
IFS=:
- if [ "`ls -dt $PATH "$CACHE" | head -n 1`" != "$CACHE" ]; then
- lsx $PATH | sort -u > "$CACHE"
+ if [ "`ls -dt $PATH "$cache" | head -n 1`" != "$cache" ]; then
+ lsx $PATH | sort -u | tee "$cache" | dmenu "$_AT_"
+ else
+ dmenu "$_AT_" < "$cache"
fi
-)
-cmd=`dmenu "$_AT_" < "$CACHE"` && exec sh -c "$cmd"
+) | read cmd && exec sh -c "$cmd"
Received on Sat Nov 19 2011 - 21:24:13 CET
This archive was generated by hypermail 2.3.0
: Sat Nov 19 2011 - 21:36:05 CET