commit c61036548411483a6284f095a028930f76bbd834
parent 89f411092eb8f38c9388055312cccbfe1c4b6bae
Author: Mahdi Mirzade <[email protected]>
Date: Thu, 2 Jun 2022 19:32:59 +0430
Swap dmenu_run with the default one, move the old one to `dmenu_run.hist`
Diffstat:
3 files changed, 1 insertion(+), 51 deletions(-)
diff --git a/dmenu_run b/dmenu_run
@@ -1,50 +1,2 @@
#!/bin/sh
-
-cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
-if [ -d "$cachedir" ]; then
- cache=$cachedir/dmenu_run
- historyfile=$cachedir/dmenu_history
-else # if no xdg dir, fall back to dotfiles in ~
- cache=$HOME/.dmenu_cache
- historyfile=$HOME/.dmenu_history
-fi
-
-IFS=:
-if stest -dqr -n "$cache" $PATH; then
- stest -flx $PATH | sort -u > "$cache"
-fi
-unset IFS
-
-awk -v histfile=$historyfile '
- BEGIN {
- while( (getline < histfile) > 0 ) {
- sub("^[0-9]+\t","")
- print
- x[$0]=1
- }
- } !x[$0]++ ' "$cache" \
- | dmenu -i "$@" \
- | awk -v histfile=$historyfile '
- BEGIN {
- FS=OFS="\t"
- while ( (getline < histfile) > 0 ) {
- count=$1
- sub("^[0-9]+\t","")
- fname=$0
- history[fname]=count
- }
- close(histfile)
- }
-
- {
- history[$0]++
- print
- }
-
- END {
- if(!NR) exit
- for (f in history)
- print history[f],f | "sort -t '\t' -k1rn >" histfile
- }
- ' \
- | while read cmd; do ${SHELL:-"/bin/sh"} -c "$cmd" & done
+dmenu_path | dmenu "$@" | ${SHELL:-"/bin/sh"} &
diff --git a/dmenu_run.def b/dmenu_run.def
@@ -1,2 +0,0 @@
-#!/bin/sh
-dmenu_path | dmenu "$@" | ${SHELL:-"/bin/sh"} &
diff --git a/dmenu_run b/dmenu_run.hist