[download]

local/bin/appsmenu

   1 #!/bin/bash
   2 
   3 f=~/.cache/${0##*/}
   4 touch $f
   5 
   6 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=term || term=
  12     done < <(grep -rlw $exec ~/.local/share/applications /usr/share/applications)
  13 
  14     ldd $(command -v $exec) | grep -q libX11.so || [[
  15         $exec == *-menu || $exec == gnome-* ||
  16         $exec == notify || $exec == *-notify
  17     ]] && term=
  18 
  19     [[ $exec == mpv ]] && args+=' --profile=pseudo-gui'
  20 
  21     $term $exec $args &
  22 done < <(
  23     join -a 2 <(sort $f) <(dmenu_path) |
  24     awk '{ $1 && a[$1]++ } END { for (i in a) print a[i], i }' |
  25     sort -k 1nr | cut -d ' ' -f 2- | menu -i apps
  26 )