diff options
author | Kris Maglione <jg@suckless.org> | 2007-05-23 16:42:51 -0400 |
---|---|---|
committer | Kris Maglione <jg@suckless.org> | 2007-05-23 16:42:51 -0400 |
commit | c04b688cc0fdfdf28eec8ca0133b7a89065ce499 (patch) | |
tree | ad6f96636909da79b8fab2b7308d4a5755a3ebe6 /dmenu_path | |
parent | dfe95cb5468618b2eb3d53d41e2ec9f4d167f3f9 (diff) |
Changed dmenu_path (fixed race, improved speed, check that $PATH is the same as the last run).
Diffstat (limited to 'dmenu_path')
-rwxr-xr-x | dmenu_path | 33 |
1 files changed, 17 insertions, 16 deletions
@@ -1,25 +1,26 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh -f |
2 | CACHE=$HOME/.dmenu_cache | 2 | CACHE=$HOME/.dmenu_cache |
3 | IFS=: | 3 | IFS=: |
4 | 4 | ||
5 | qfind() { | ||
6 | find "$@" 2>/dev/null | ||
7 | } | ||
8 | |||
5 | uptodate() { | 9 | uptodate() { |
6 | test ! -f $CACHE && return 1 | 10 | test -f $CACHE && |
7 | for dir in $PATH | 11 | test "$(echo "$PATH")" = "$(sed 1q "$CACHE")" && |
8 | do | 12 | qfind $PATH -maxdepth 0 -newer $CACHE |
9 | test $dir -nt $CACHE && return 1 | 13 | } |
10 | done | ||
11 | return 0 | ||
12 | } | ||
13 | 14 | ||
14 | if ! uptodate | 15 | if ! uptodate |
15 | then | 16 | then |
16 | for dir in $PATH | 17 | { |
17 | do | 18 | echo "$PATH" |
18 | for file in "$dir"/* | 19 | qfind $PATH -type f -maxdepth 1 -perm -u+x -o -perm -g+x -o -perm -o+x | |
19 | do | 20 | sed 's,.*/,,' | sort | uniq |
20 | test -x "$file" && echo "${file##*/}" | 21 | } > $CACHE.$pid |
21 | done | 22 | mv $CACHE.$pid $CACHE |
22 | done | sort | uniq > $CACHE | ||
23 | fi | 23 | fi |
24 | 24 | ||
25 | cat $CACHE | 25 | tail -n +2 $CACHE |
26 | |||