#1  
Old 30th June 2008, 18:07
nightfire nightfire is offline
Junior Member
 
Join Date: May 2008
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
Default Help With GUI Menu

OK, I very, very, very new at this and don't know what I doing. I'm really trying so try to be kind . Here is what I'm trying to do. I have this script that I'm working on.


Code:
#!/bin/sh 

# this is my first menu script. 
# I'm tring to get Zenity to work with it So I can have a full GUI Menu 
if [ $(whoami) != "root" ] ; then 
      zenity --error \ 
          --text="Please Run This as Root" 
exit 1 
fi 



clear; 
        echo "Hello, What would you like me to install for you? " 
        
        sleep 1 
        
# GUI Menu I am Tring to get to work 
#zenity --height=600 --width=800 \ 
#         --title="Install Menu" \ 
#         --text="Pick your Poison" \ 
#         --list \ 
#         --checklist \ 
#         --column="Pick This" \ 
#    --column="#" \ 
#    --column="Program" \ 
#         --column="Action" \ 
#          "False" "1" "Backgrounds" "(These are a colection from the all over the internet)" \ 
#          "False" "2" "Backgrounds" "(These are a colection from http://wallpapers-n-etc.com)" \ 
#          "False" "3" "icons" "(This will install some extra icon sets from gnome-look)" \ 
#          "False" "4" "Video setup" "(This will install DVD Playback Codecs and Players)" \ 
#          "False" "5" "themes" "(This will add some Extra Themes for gnome)" \ 
#          "False" "6" "compiz fusion" "(This will install Compiz Fusion from Fedora Repo)" \ 
#          "False" "7" "awn" "(This will install the AWN Dock)" \ 
          







#The Menu 
        echo "..........................." 
        echo "...........MENU............" 
        echo 
        echo "1 Backgrounds 1" "(These are a colection from the all over the internet)" 
   echo "2 Backgrounds 2" "(These are a colection from http://wallpapers-n-etc.com)" 
        echo "3 icons"  "(This will install some extra icon sets from gnome-look)" 
#        echo "4 Video setup"  "(This will install DVD Playback Codecs and Players)" 
#Still working on this 
        echo "5 themes"  "(This will add some Extra Themes for gnome)" 
        echo "6 compiz fusion"  "(This will install Compiz Fusion from Fedora Repo)" 
        echo "7 awn"  "(This will install the AWN Dock)" 

#Execute Menu Choice        
        read choice 
       
        while [[ $choice != 0 ]] 
        do 
           case $choice in 
             1)  clear; 
       rpm -Uvh 'http://192.168.2.4/downloads/nfbackgrounds-1-1.fc9.noarch.rpm' 
       P=nfbackgrounds 
       rpm -qa "$P" > tl 
       my_size=$( wc -l < t1 ) 
       echo "Checking install status" 
       if [[ $( rpm -qa $P ) =~ ${P} ]] 
       then 
        zenity --info \ 
                --text="Backgrounds were installed.  Right click on desktop to change Background" 
       else 
         zenity --error \ 
             --text="Backgrounds Were not installed" 
       fi 
       rm t1                
                 ;; 
        2)  clear; 
       rpm -Uvh 'http://192.168.2.3/downloads/nfbackground2-1-1.fc9.noarch.rpm' 
       P=nfbackgrounds2 
       rpm -qa "$P" > t1 
       my_size=$( wc -l < t1 ) 
       echo "Checking install status" 
       if [[ $( rpm -qa $P ) =~ ${P} ]] 
       then 
        zenity --info \ 
                --text="Backgrounds were installed.  Right click on desktop to change Background" 
       else 
         zenity --error \ 
             --text="Backgrounds Were not installed" 
       fi 
       rm t1                
       ;; 
             3)  clear; 
       yum -y install wget 
       wget 192.168.2.4/downloads/nficons.tar.gz 
       tar zxvf nficons.tar.gz -C /usr/share/icons 
       rm nficons.tar.gz 
                 ;; 
             4)  clear; 
                 su -c 'rpm -i http://rpm.livna.org/livna-release-8.rpm' 
       wget 192.168.2.4/downloads/dvdplayback.sh 
       sh dvdplayback.sh 
       rm dvdplayback.sh 
                 ;; 
             5)  clear; 
       yum -y install wget 
                 wget 192.168.2.4/downloads/nfthemesf8.tar.gz 
                 tar zxvf nfthemesf8.tar.gz -C /usr/share/themes 
       rm nfthemesf8.tar.gz 
       ;; 
             6)  clear; 
                 yum -y install ccsm emerald-themes compizconfig-backend-kconfig compizconfig-backend-gconf fusion-icon* emerald compiz-fusion compiz-fusion-gnome libcompizconfig compiz-gnome compiz-bcop compiz compizconfig-python compiz-fusion-extras compiz-fusion-extras-gnome compiz-kde 
       P=compiz-fusion-gnome 
       rpm -qa "$P" > t1 
       my_size=$( wc -l < t1 ) 
       echo "Checking install status" 
       if [[ $( rpm -qa $P ) =~ ${P} ]] 
       then 
        zenity --info \ 
                --text="compiz fusion was installed." 
       else 
         zenity --error \ 
             --text="compiz fusion was not installed" 
       fi 
       rm t1 
                 ;; 
             7)  clear; 
                 yum -y install avant-window-navigator awn-extras 
                 P=avant-window-navigator 
       rpm -qa "$P" > t1 
       my_size=$( wc -l < t1 ) 
       echo "Checking install status" 
       if [[ $( rpm -qa $P ) =~ ${P} ]] 
       then 
        zenity --info \ 
                --text="avant-window-navigator was installed." 
       else 
         zenity --error \ 
             --text="avant-window-navigator was not installed" 
       rm tl 
       fi 
       ;; 
             *)  clear; 
                 echo "You have entered an invalid option!" 
                 ;; 
           esac 

#Menu Loop 
        echo "..........................." 
        echo "...........MENU............" 
        echo 
        echo "1 Backgrounds 1" "(These are a colection from the all over the internet)" 
   echo "2 Backgrounds 2" "(These are a colection from http://wallpapers-n-etc.com)" 
        echo "3 icons"  "(This will install some extra icon sets from gnome-look)" 
#        echo "4 Video setup"  "(This will install DVD Playback Codecs and Players)" 
        echo "5 themes"  "(This will add some Extra Themes for gnome)" 
        echo "6 compiz fusion"  "(This will install Compiz Fusion from Fedora Repo)" 
        echo "7 awn"  "(This will install the AWN Dock)" 

         read choice 
      done
Now what I'm trying to get working is the Zenity Menu. If I take the away the #'s the menu comes up the way I want it to. But my problem is how do I get it to run the commands that I have listed here 1-7? This is where I'm stuck. Hope I'm making sense and someone can help. If i run the script as is It work fine but it has to loop back after one command. I want it to have a GUI and be able to select more then one item to install at a time.
Thanks in advance for the help.
__________________
Thanks,
Night Fire
Linux Tips, Tricks and Guides for Fedora 8
Reply With Quote
Sponsored Links
  #2  
Old 1st July 2008, 13:57
burschik burschik is offline
Junior Member
 
Join Date: May 2008
Posts: 24
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Apparently, you are not using the return value(s) of zenity. Try this:

HTML Code:
read -a choice  <<EOF
$(zenity --height=600 --width=800 \
         --title="Install Menu" \
         --list \
         --checklist \
         --column="Pick This" \
    --column="#" \
    --column="Program" \
         --column="Action" \
          "False" "1" "Backgrounds" "(These are a colection from the all over the internet)" \
          "False" "2" "Backgrounds" "(These are a colection from http://wallpapers-n-etc.com)" \
          "False" "3" "icons" "(This will install some extra icon sets from gnome-look)" \
          "False" "4" "Video setup" "(This will install DVD Playback Codecs and Players)" \
          "False" "5" "themes" "(This will add some Extra Themes for gnome)" \
          "False" "6" "compiz fusion" "(This will install Compiz Fusion from Fedora Repo)" \
          "False" "7" "awn" "(This will install the AWN Dock)" | tr '|' ' ')
EOF

echo "${choice[@]}"
Reply With Quote
  #3  
Old 1st July 2008, 14:42
nightfire nightfire is offline
Junior Member
 
Join Date: May 2008
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
Default getting there :)

Burschik, Thank you for the help. If you can suggest some good books out there so I can learn this better that would be great. I'm finding info here and there around the net but don't under stand what allot of the variables are yet. So with this project here is where I stand. The Zenity menu now will run the command but it stays in a loop. It just keeps running the same one. So if I pick 3 programs to install it just loops the 1st one. I know this more advance and probably shouldn't be attempting to do this but I'm more of hands on then reader to understand things.

Code:
#!/bin/sh 

# this is my first menu script. 
# I'm tring to get Zenity to work with it So I can have a full GUI Menu 
#if [ $(whoami) != "root" ] ; then 
#      zenity --error \ 
#         --text="Please Run This as Root" 
#exit 1 
#fi 



clear; 
        echo "Hello, What would you like me to install for you? " 
        
        sleep 1 
        
read -a choice  <<EOF
$(zenity --height=400 --width=800 \
         --title="Install Menu" \
         --list \
         --checklist \
         --column="Pick This" \
    --column="#" \
    --column="Program" \
         --column="Action" \
          "False" "1" "Backgrounds" "(These are a colection from the all over the internet)" \
          "False" "2" "Backgrounds" "(These are a colection from http://wallpapers-n-etc.com)" \
          "False" "3" "icons" "(This will install some extra icon sets from gnome-look)" \
          "False" "4" "Video setup" "(This will install DVD Playback Codecs and Players)" \
          "False" "5" "themes" "(This will add some Extra Themes for gnome)" \
          "False" "6" "compiz fusion" "(This will install Compiz Fusion from Fedora Repo)" \
          "False" "7" "awn" "(This will install the AWN Dock)" | tr '|' ' ')
EOF

echo "${choice[@]}"


       
        while [[ $choice != 0 ]] 
        do 
           case $choice in 
             1)  clear; 
       rpm -Uvh 'http://192.168.2.4/downloads/nfbackgrounds-1-1.fc9.noarch.rpm' 
       P=nfbackgrounds 
       rpm -qa "$P" > tl 
       my_size=$( wc -l < t1 ) 
       echo "Checking install status" 
       if [[ $( rpm -qa $P ) =~ ${P} ]] 
       then 
        zenity --info \ 
                --text="Backgrounds were installed.  Right click on desktop to change Background" 
       else 
         zenity --error \ 
             --text="Backgrounds Were not installed" 
       fi 
       rm t1                
                 ;; 
        2)  clear; 
       rpm -Uvh 'http://192.168.2.3/downloads/nfbackground2-1-1.fc9.noarch.rpm' 
       P=nfbackgrounds2 
       rpm -qa "$P" > t1 
       my_size=$( wc -l < t1 ) 
       echo "Checking install status" 
       if [[ $( rpm -qa $P ) =~ ${P} ]] 
       then 
        zenity --info \ 
                --text="Backgrounds were installed.  Right click on desktop to change Background" 
       else 
         zenity --error \ 
             --text="Backgrounds Were not installed" 
       fi 
       rm t1                
       ;; 
             3)  clear; 
       yum -y install wget 
       wget 192.168.2.4/downloads/nficons.tar.gz 
       tar zxvf nficons.tar.gz -C /usr/share/icons 
       rm nficons.tar.gz 
                 ;; 
             4)  clear; 
                 su -c 'rpm -i http://rpm.livna.org/livna-release-8.rpm' 
       wget 192.168.2.4/downloads/dvdplayback.sh 
       sh dvdplayback.sh 
       rm dvdplayback.sh 
                 ;; 
             5)  clear; 
       yum -y install wget 
                 wget 192.168.2.4/downloads/nfthemesf8.tar.gz 
                 tar zxvf nfthemesf8.tar.gz -C /usr/share/themes 
       rm nfthemesf8.tar.gz 
       ;; 
             6)  clear; 
                 yum -y install ccsm emerald-themes compizconfig-backend-kconfig compizconfig-backend-gconf fusion-icon* emerald compiz-fusion compiz-fusion-gnome libcompizconfig compiz-gnome compiz-bcop compiz compizconfig-python compiz-fusion-extras compiz-fusion-extras-gnome compiz-kde 
       P=compiz-fusion-gnome 
       rpm -qa "$P" > t1 
       my_size=$( wc -l < t1 ) 
       echo "Checking install status" 
       if [[ $( rpm -qa $P ) =~ ${P} ]] 
       then 
        zenity --info \ 
                --text="compiz fusion was installed." 
       else 
         zenity --error \ 
             --text="compiz fusion was not installed" 
       rm t1 
       fi 
       ;; 
             7)  clear; 
                 yum -y install avant-window-navigator awn-extras 
                 P=avant-window-navigator 
       rpm -qa "$P" > t1 
       my_size=$( wc -l < t1 ) 
       echo "Checking install status" 
       if [[ $( rpm -qa $P ) =~ ${P} ]] 
       then 
        zenity --info \ 
                --text="avant-window-navigator was installed." 
       else 
         zenity --error \ 
             --text="avant-window-navigator was not installed" 
       rm tl 
       fi 
       ;; 
             *)  clear; 
                 echo "You have entered an invalid option!" 
                 ;; 
           esac 

      done
Thanks again in advance
__________________
Thanks,
Night Fire
Linux Tips, Tricks and Guides for Fedora 8
Reply With Quote
  #4  
Old 1st July 2008, 15:27
burschik burschik is offline
Junior Member
 
Join Date: May 2008
Posts: 24
Thanks: 0
Thanked 2 Times in 2 Posts
 
Default

Try the Advanced Bash Scripting Guide at http://tldp.org/LDP/abs/html/

You need to understand that "choice" is an array variable. For this reason, "$choice" only returns the first element of the array. You need to iterate over all array elements.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mac And A Flash Menu Problem? Jena Programming/Scripts 2 26th October 2008 10:29
kernel compile error/ndiswrapper error Droogie Kernel Questions 1 28th April 2008 21:38
Post GUI install willebanks Installation/Configuration 2 11th February 2008 16:51
Greek Support on ISPConfig 2.2.14, lost tools menu pssara General 6 8th July 2007 18:59
unable to login root in GUI Mode in Suse10 saialkesh HOWTO-Related Questions 12 2nd May 2006 09:57


All times are GMT +2. The time now is 16:51.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.