[download]

local/bin/apps-menu

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