From 5b2b8cb6ed8834c21fb707ae834e0111f33c2d91 Mon Sep 17 00:00:00 2001 From: Jack-Benny Persson Date: Thu, 26 Dec 2013 11:28:04 +0100 Subject: [PATCH] Started to re-write the dialog exercises to use Zenity instead --- Labb7/laborationsrapport.md | 9 +++++++++ Labb7/ovning1_zenity.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 Labb7/ovning1_zenity.sh diff --git a/Labb7/laborationsrapport.md b/Labb7/laborationsrapport.md index 48c8c68..2e9af86 100644 --- a/Labb7/laborationsrapport.md +++ b/Labb7/laborationsrapport.md @@ -6,6 +6,15 @@ Kunna implementera dialog med bash-scripting. ## Tillvägagångssätt ## Här var det väldigt mycket nytt att lära sig så här kommer dokumentationen bli något större än tidigare labbar. +Både Dialog och Zenity är för mig helt nytt. + +### Dialog ### +_--backtitle_ är det som visas i bakgrunden överst på skärmen i dialogrutorna. Måtten t.ex. +10 60 som används i labbexemplen är tecken, alltså 10 tecken hög och 60 tecken bred. + +### Zenity ### +Zenity är hur coolt som helst. Att kunna skapa GUI-applikationer utav sina shellscripts är hur +kul som helst! ## Reflektion ## diff --git a/Labb7/ovning1_zenity.sh b/Labb7/ovning1_zenity.sh new file mode 100755 index 0000000..0e5c77d --- /dev/null +++ b/Labb7/ovning1_zenity.sh @@ -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