#!/bin/bash # Menu from CLI to start X programs # set -x . /home/default # No need to change anything below # The parameters. TEXT="Menu from CLI to start X programs" #Check if dialog is installed type -P $DIALOG &>/dev/null || { echo "'$DIALOG' is required, but it's not installed. Aborting." >&2 exit 1; } #Program specific DIR=/usr/share/applications ### End parameters #Get the list of programs grep -R ^Exec $DIR|grep -v yast|awk -F= '{print $NF}'|awk '{print $1}'|sort -u| while read CMDR do basename $CMDR >> $TMP.cmd done # Make the cmd list for --menu for CMD in `cat $TMP.cmd` do INFO="`whatis $CMD | \ head -n 1| \ sed 's/: nothing appropriate.//g' | \ sed 's/(.*)//'| \ awk -F' - ' '{print $NF}'`" echo "$CMD \"$INFO\" \"$INFO\"" >> $TMP.mnu done #Turn it all into a menu eval "menu=( $(< $TMP.mnu) )" $DIALOG --backtitle "$TEXT" \ --item-help --title "Program selector" \ --menu "Please select one of the programs to run" 40 60 40 \ "${menu[@]}" \ 2> $TMP #Run the command if possible KEY=$? CHOICE=`cat $TMP` clear case $KEY in 0) echo "'$CHOICE' will run. If not, use standard console." exec $CHOICE > /dev/null 2>&1 & ;; 1) echo "Cancel selected";; 2) echo "Help selected";; 255) echo "ESC selected";; esac # exit