#!/bin/bash # XFCE Menu adder # set -x # Parameters. These must exist DIR="$HOME/.local/share/applications" CMDZ="zenity" CMDK="kdialog" MENUDIR="/etc/xdg/menus/xfce-applications.menu" #Exit if empty TRYAGAIN () { $CMDZ --text="Sorry no selection or wrong selection. Please try again in the near future and now try to do it correct you utter noob" --warning exit } # Data entry NAME=`$CMDZ --text="Name of the command" --entry|sed -e "s/ /_/g"` if [ -z $NAME ];then TRYAGAIN;fi COMMENT=`$CMDZ --text="Comment for the command" --entry` if [ -z $COMMENT ];then TRYAGAIN;fi CATEGORIES=`$CMDZ --list --column 'Category' --text="Select the Category" --print-column 1 $(grep '' /etc/xdg/menus/xfce-applications.menu|awk -F'>' '{print $2}'|awk -F'<' '{print $1}')` if [ -z $CATEGORIES ];then TRYAGAIN;fi EXEC=`$CMDK --getopenfilename $HOME/bin/` if [ -z $EXEC ];then TRYAGAIN;fi ICON=`$CMDK --geticon a` kdialog --warningyesnocancel "Do you\nwant to open\nwithout a terminal?" CHOICE=$? case $CHOICE in 0) TERMINAL=false;; 1) TERMINAL=true;; 2) TRYAGAIN;; *) TRYAGAIN;; esac # Write the file cat > ${DIR}/${NAME}.desktop <<-EOF [Desktop Entry] Version=1.0 Encoding=UTF-8 Type=Application Name=$NAME Comment=$COMMENT Categories=${CATEGORIES}; Exec=$EXEC Icon=$ICON Terminal=$TERMINAL StartupNotify=false EOF # Restart killall -HUP xfdesktop exit