[download]

local/bin/apps-menu

   1 #!/bin/bash
   2 
   3 f=~/.cache/apps-menu && touch $f
   4 
   5 join -a 2 <(sort $f) <(dmenu_path) | awk '{ $1 && a[$1]++ } END { for (i in a) print a[i], i }' |
   6 sort -k 1nr | cut -d ' ' -f 2- | menu -i apps | while read exec args; do
   7     term=term
   8     echo "$exec $args" >> $f
   9 
  10     while read i; do
  11         grep -qiw terminal=true $i || term=
  12         read _ arg < <(grep -i '^exec=' $i | sed 's/%.//')
  13         args+=" $arg"
  14     done < <(grep -rlw $exec ~/.local/share/applications /usr/share/applications)
  15 
  16     ldd $(command -v $exec) | grep -q libX11.so ||
  17     [[ $exec == *-menu ]] || [[ $exec == notify ]] ||
  18     [[ $exec == *-notify ]] && term=
  19 
  20     $term $exec $args &
  21 done