From a02a1a662362a1e74f627c7f47335b5aeda79c67 Mon Sep 17 00:00:00 2001 From: Connor Lane Smith Date: Sat, 19 Nov 2011 21:24:07 +0100 Subject: faster dmenu_run -f --- dmenu_run | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'dmenu_run') diff --git a/dmenu_run b/dmenu_run index 2747919..cf75b0a 100755 --- a/dmenu_run +++ b/dmenu_run @@ -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 "$@" + else + dmenu "$@" < "$cache" fi -) -cmd=`dmenu "$@" < "$CACHE"` && exec sh -c "$cmd" +) | read cmd && exec sh -c "$cmd" -- cgit v1.2.3-13-gbd6f