diff options
author | Connor Lane Smith <cls@lubutu.com> | 2011-11-19 21:24:07 +0100 |
---|---|---|
committer | Connor Lane Smith <cls@lubutu.com> | 2011-11-19 21:24:07 +0100 |
commit | a02a1a662362a1e74f627c7f47335b5aeda79c67 (patch) | |
tree | 94f400009604dba782a7aa4b9afbb40238f5c46b | |
parent | 8ac44eb75a3e2190aa7b89548956b2de33c5a6ce (diff) |
faster dmenu_run -f
-rw-r--r-- | dmenu.c | 2 | ||||
-rwxr-xr-x | dmenu_run | 17 |
2 files changed, 11 insertions, 8 deletions
@@ -117,7 +117,7 @@ main(int argc, char *argv[]) { | |||
117 | setup(); | 117 | setup(); |
118 | run(); | 118 | run(); |
119 | 119 | ||
120 | return EXIT_FAILURE; /* unreachable */ | 120 | return 1; /* unreachable */ |
121 | } | 121 | } |
122 | 122 | ||
123 | void | 123 | void |
@@ -1,12 +1,15 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | CACHE=${XDG_CACHE_HOME:-"$HOME/.cache"}/dmenu_run | 2 | cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"} |
3 | if [ ! -d "`dirname "$CACHE"`" ]; then | 3 | if [ -d "$cachedir" ]; then |
4 | CACHE=$HOME/.dmenu_cache | 4 | cache=$cachedir/dmenu_run |
5 | else | ||
6 | cache=$HOME/.dmenu_cache | ||
5 | fi | 7 | fi |
6 | ( | 8 | ( |
7 | IFS=: | 9 | IFS=: |
8 | if [ "`ls -dt $PATH "$CACHE" | head -n 1`" != "$CACHE" ]; then | 10 | if [ "`ls -dt $PATH "$cache" | head -n 1`" != "$cache" ]; then |
9 | lsx $PATH | sort -u > "$CACHE" | 11 | lsx $PATH | sort -u | tee "$cache" | dmenu "$@" |
12 | else | ||
13 | dmenu "$@" < "$cache" | ||
10 | fi | 14 | fi |
11 | ) | 15 | ) | read cmd && exec sh -c "$cmd" |
12 | cmd=`dmenu "$@" < "$CACHE"` && exec sh -c "$cmd" | ||