On Sun, Sep 11, 2011 at 11:09 PM, Dieter Plaetinck <dieter_AT_plaetinck.be> wrote:
> * stable sort. @CLS why I want this: say, for an application launcher, if I
> provide input to dmenu ordered by frequency, that means commands at
> the top are more important then those that come after. (where important
> means: is more likely to be the option the user is looking for)
I'm not really sure what does "stable sort" means, but I modified my
dmenu_run script to make it have some sort of history in
most-recently-used order.
Here it is, in case it's useful:
## Begin of script
#!/bin/sh
HISTORY=${XDG_CONFIG_HOME:-"$HOME/.config"}/dmenu_run.history
CACHE=${XDG_CACHE_HOME:-"$HOME/.cache"}/dmenu_run
(
IFS=: # for $PATH :-sepparated entries
if test "`ls -dt $PATH "$HISTORY" "$CACHE" 2> /dev/null | sed 1q`" !=
"$CACHE"; then
# Add all the executables in PATH
mkdir -p "`dirname "$CACHE"`" && lsx $PATH | sort -u >> "$CACHE"
fi
)
cmd=$(tac "$HISTORY" "$CACHE" | dmenu "$@") || exit
{ # Update history in background
(echo "g/${cmd}/d"; echo 'wq') | ex -s "$HISTORY"
echo "$cmd" >> "$HISTORY"
} &
exec sh -c "$cmd"
## End of script
-- Fernando Carmona VaroReceived on Fri Sep 16 2011 - 03:14:42 CEST
This archive was generated by hypermail 2.2.0 : Fri Sep 16 2011 - 03:24:03 CEST