aboutsummaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
authortdro <tdro@users.noreply.github.com>2020-08-26 00:12:49 -0400
committertdro <tdro@users.noreply.github.com>2020-08-26 00:12:49 -0400
commit0863b74a8962024e2eb79cfbc0cf2ff2a2b43b33 (patch)
tree9b88794b1cf72b71fc8c559e5794413acbc5bfeb /.local
parentd94b406e09fabcb349ef9011ff022a8a015d5e4b (diff)
downloaddotfiles-0863b74a8962024e2eb79cfbc0cf2ff2a2b43b33.tar.gz
dotfiles-0863b74a8962024e2eb79cfbc0cf2ff2a2b43b33.tar.bz2
dotfiles-0863b74a8962024e2eb79cfbc0cf2ff2a2b43b33.zip
.local/bin: Add dmenu_run_history
Rofi is kinda slow.
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/dmenu_run_history50
-rwxr-xr-x.local/bin/scripts/app-launcher7
2 files changed, 54 insertions, 3 deletions
diff --git a/.local/bin/dmenu_run_history b/.local/bin/dmenu_run_history
new file mode 100755
index 0000000..eb06af1
--- /dev/null
+++ b/.local/bin/dmenu_run_history
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
+if [ -d "$cachedir" ]; then
+ cache=$cachedir/dmenu_run
+ historyfile=$XDG_DATA_HOME/dmenu_history
+else
+ 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 -b "$@" \
+ | 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 -r cmd; do ${SHELL:-"/bin/sh"} -c "$cmd" & done
diff --git a/.local/bin/scripts/app-launcher b/.local/bin/scripts/app-launcher
index b689da6..0fe9cbe 100755
--- a/.local/bin/scripts/app-launcher
+++ b/.local/bin/scripts/app-launcher
@@ -1,4 +1,5 @@
#!/bin/sh
-xset r rate 200 25;
-rofi -cache-dir "$HOME/.local/share" -fullscreen -show run -display-run '$' -font 'ubuntu 12' -padding 250;
-xset r rate 200 60;
+
+# rofi -cache-dir "$HOME/.local/share" -fullscreen -show run -display-run '$' -font 'ubuntu 12' -padding 250;
+
+dmenu_run_history;