Started to re-write the dialog exercises to use Zenity instead
This commit is contained in:
33
Labb7/ovning1_zenity.sh
Executable file
33
Labb7/ovning1_zenity.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Jack-Benny Persson
|
||||
# LX13
|
||||
# Övning 1 (Make a menu that let's the user choose a web browser)
|
||||
|
||||
# Binaries
|
||||
Zenity="/usr/bin/zenity"
|
||||
Whereis="/usr/bin/whereis"
|
||||
|
||||
# Santiy checks
|
||||
if [ ! -x $Zenity ]; then
|
||||
echo "Can't excute $Zenity"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Main
|
||||
$Zenity --text "Choose a browser" --list --column="Start"\
|
||||
--column "Browser" --radiolist FALSE firefox FALSE lynx FALSE links FALSE w3m\
|
||||
> /tmp/browserchoice
|
||||
Browser=`cat /tmp/browserchoice`
|
||||
|
||||
BinPath=`$Whereis $Browser | awk '{ print $2 }'`
|
||||
|
||||
echo $BinPath | grep / &> /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
$Zenity --info --text="It seems you don't have $Browser installed"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
$BinPath &
|
||||
|
||||
exit 0
|
Reference in New Issue
Block a user