Re: [dev] [dmenu] dmenu_run improvements

From: lolilolicon <lolilolicon_AT_gmail.com>
Date: Sun, 24 Jul 2011 14:34:22 +0800

On 07/24/11 at 01:34am, Dave Reisner wrote:
> #!/bin/sh
>
> CACHE=${XDG_CACHE_HOME:-"$HOME/.cache"}/dmenu_run
> IFS=:
> LC_COLLLATE=C
You got a typo here: LC_COLLATE

>
> gencache() {
> lsx $PATH | sort -u >"$CACHE"
> }
Since LC_COLLATE is only used for sort, we might as well just use:

  LC_COLLATE=C sort

>
> if [ ! -e "$CACHE" ]; then
> mkdir -p "${CACHE%/*}"
> gencache
> fi
>
> for path in $PATH; do
> if [ "$path" -nt "$CACHE" ]; then
> gencache
> break
> fi
> done
Much better than `ls -t', congratulations.
If $CACHE does not exist, there's no need to compare timestamps, so
let's puts an `else' there.

> unset IFS
>
> cmd=$(dmenu "$@" < "$CACHE") && eval exec "$cmd"
Yeah, I see you just hate backticks :P
Received on Sun Jul 24 2011 - 08:34:22 CEST

This archive was generated by hypermail 2.2.0 : Sun Jul 24 2011 - 08:36:03 CEST