#!/bin/bash ## I probably used bashisms here, so we run with bash ## This Script detects what dialog to use in an X session from (currently) 3 options, ## Kdialog, the KDE/Qt dialog ## Zenity, the Gnomw/GTK dialog ## Xdialog, the generic X dialog # First we initialise our DIALOG variable, so if all check fail, we can tell DIALOG='' # DIALOGS is the list of dialog apps we want to check for DIALOGS="kdialog zenity xdialog" # Now we check that the user is in a GUI session if [ -z $DISPLAY ] then echo "DISPLAY not set" >&2 # we post an error message to the terminal exit 1 # and exit here fi # Now we start checking for the dialog apps for i in $DIALOGS do if [ -x /usr/bin/$i ] # Check the app exists (and is executable) then DIALOG=$i # if it exists, then set DIALOG to it break # and stop checking, if it doesn't exist fi # then it moves to the next dialog to check. done if [ -z $DIALOG ] # If DIALOG wasn't set then we have no dialog app then if [ -x /usr/bin/xmessage ] # we check for xmessage ( a basic text box installed with X) then xmessage "No dialog application was found. You need one of kdialog (for Kubuntu), zenity (for Ubuntu/Edubuntu/Xubuntu) or xmessage (generic)." # and print a message for the user else echo "No dialog application was found. You need one of kdialog (for Kubuntu), zenity (for Ubuntu/Edubuntu/Xubuntu) or xmessage (generic)." # if xmessage isn't installed (god knows why), then print the message to the terminal fi exit 1 # and die fi