aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/dmenu_run_history
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/dmenu_run_history')
-rwxr-xr-x.local/bin/dmenu_run_history51
1 files changed, 28 insertions, 23 deletions
diff --git a/.local/bin/dmenu_run_history b/.local/bin/dmenu_run_history
index c6a7372..ba9b2af 100755
--- a/.local/bin/dmenu_run_history
+++ b/.local/bin/dmenu_run_history
@@ -1,27 +1,31 @@
#!/bin/sh
-[ "$1" = "privilege" ] && export cmd_prefix='sudo -A ' && export dmenu_args='-p Privilege -sb red' && shift 1;
-[ "$1" = "terminal" ] && export cmd_prefix='urxvt -hold -e ' && export dmenu_args='-p Terminal -sb gray' && shift 1;
-
# https://tools.suckless.org/dmenu/scripts/
+[ "$1" = "privilege" ] &&
+ export cmd_prefix='rofi-askpass ' &&
+ export dmenu_args='-nhf #ff7070 -sf #ff7070 -p ⠀:::⠀privilege⠀:::' &&
+ shift 1
+
+[ "$1" = "terminal" ] &&
+ export cmd_prefix='urxvt -hold -e ' &&
+ export dmenu_args='-nhf #9e9e9e -sf #9e9e9e -p ⠀:::⠀terminal⠀:::' &&
+ shift 1
+
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
-
-if [ "$1" = "update" ] || [ ! -f "$cache" ]; then
- IFS=:
- stest -dqr -n "$cache" $PATH && stest -flx $PATH | sort -u > "$cache";
- unset IFS;
- exit;
-fi
-
-awk -v histfile=$historyfile '
+cache=$cachedir/dmenu_run
+historyfile=$XDG_DATA_HOME/dmenu_history
+mkdir --parents "$cachedir"
+
+update() {
+ IFS=:
+ stest -flx $PATH | sort -u >"$cache"
+ unset IFS
+}
+
+[ ! -f "$cache" ] && update
+
+awk -v histfile="$historyfile" '
BEGIN {
while( (getline < histfile) > 0 ) {
sub("^[0-9]+\t","")
@@ -29,8 +33,8 @@ awk -v histfile=$historyfile '
x[$0]=1
}
} !x[$0]++ ' "$cache" \
- | dmenu -b ${dmenu_args:--p Launch} "$@" \
- | awk -v histfile=$historyfile '
+ | dmenu -i -b ${dmenu_args:--p ⠀:::⠀execute⠀:::} "$@" \
+ | awk -v histfile="$historyfile" '
BEGIN {
FS=OFS="\t"
while ( (getline < histfile) > 0 ) {
@@ -52,5 +56,6 @@ awk -v histfile=$historyfile '
for (f in history)
print history[f],f | "sort -t '\t' -k1rn >" histfile
}
- ' \
- | while read -r cmd; do ${SHELL:-"/bin/sh"} -c "$cmd_prefix $cmd" & done
+ ' | while read -r cmd; do ${SHELL:-"/bin/sh"} -c "$cmd_prefix $cmd" & done
+
+update