Files
hyprdots/hypr/dmenu_run_history
2024-08-02 12:06:22 +05:30

34 lines
754 B
Bash
Executable File

#!/bin/sh
cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
cache=$cachedir/dmenu_run
historyfile=$cachedir/dmenu_history
ls /bin >"$cache"
cut -f2 "$historyfile" "$cache" | bemenu -R 20 --fixed-height --fn 'JetBrainsMono Nerd Font 15' -i -c -W 0.5 -B 3 -p "RUN: " -l 15 -P ">>" --bdr="#$GLOBAL_ACCENT" --tf="#$GLOBAL_ACCENT" --hf="#$GLOBAL_ACCENT" |
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