Nimbin[12]?Useful / bemenu-my-run

bemenu-my-run Useful

This script is creating a dmenu like menu.
It uses bemenu for wayland.
It gets all entries from /user/share/applications.
It prefears entries from ~/.local/share/applications.
https://github.com/Cloudef/bemenu

wget https://git.christianimmanuel.de/scripts/raw/Useful/bemenu-my-run && chmod 740 bemenu-my-run
bemenu-my-run 1.2 KB · 40 lines raw
#!/bin/bash

#################################################
### This script is creating a dmenu like menu.
### It uses bemenu for wayland.
### It gets all entries from /user/share/applications.
### It prefears entries from ~/.local/share/applications.
### https://github.com/Cloudef/bemenu

mkdir -p $HOME/.cache/bemenu/
LOG="$HOME/.cache/bemenu/last"
touch "$LOG"

CHOICES="$(grep -m1 "Name=" /usr/share/applications/* | sed "s/^\/usr\/share\/applications\///g"| awk -F ':Name=' '{print "gtk-launch ", $1, " ^ ", $2}')"

while read -r line; do
   CHOICES="$(echo "$CHOICES" | sed /"$line"/d )"
done < "$LOG"

CHOICES="$(echo -e "$(cat "$LOG")\n$CHOICES")"

logCMD() {
   INPUT="$CMD^$PICKED"
   sed -i /"$INPUT"/d "$LOG"
   if wc -l "$LOG" | grep -w "0"; then
      echo "$INPUT" > "$LOG"
   else
      sed -i "1s/^/$INPUT\n/" "$LOG"
   fi
}

echo "$CHOICES" |
   cut -d'^' -f2 |
   bemenu -i -c -l10 -W0.2 --fn="Breeze_Hacked 18" -p=" " --nf="#ffffff" --nb="#89afc4" --hb="#002845" --fb="#002845" --tb="#002845" --tf="#002845" --ff="#cb9b00" --hf="#89afc4" |  (
      PICKED="$(cat)"
      echo "$PICKED" | grep . || exit 0
      CMD="$(echo "$CHOICES" | grep -m1 -F "$PICKED" | cut -d '^' -f1)"
      eval "$CMD" &&
         logCMD "$CMD" "$PICKED"
   )