Results 1 to 4 of 4

Thread: can someone explain to me this .sh file(uses YAD and zenity)

  1. #1
    Join Date
    Jan 2013
    Beans
    29

    Question can someone explain to me this .sh file(uses YAD and zenity)

    everything is important but what I most need is to know where the commands that tell the commands of the drop down menu start and end
    Code:
    action=$(yad --width 300 --entry --title "Anime navigation GUI" \
        --image=/home/froylan/Pictures/11220.png \
        --button="ok:2" --button="cancel" \
        --text "select anime:" \
        --entry-text \
        "hyouka" "beelzebub" "Blassreiter" "hellsing Ultimate" "Kemeko Deluxe" "Angel Beats!" )
        ret=$?
    [[ $ret -eq 1 ]] && exit 0
    
    if [[ $ret -eq 1 ]]; then
    vlc ~/Music/Tutturuu~.mp3
     exit 0
    fi
    
    case $action in
        hyouka*) cmd="vlc -f ~/anime/[Mazui]_Hyouka_[720p]" ;;
        beelzebub*) cmd="vlc -f ~/anime/Beelzebub" ;;
        Blassreiter*) cmd="vlc -f ~/anime/Blassreiter" ;;
        hellsing*) cmd="vlc -f ~/anime/Hellsing\ Ultimate" ;;
        Kemeko*) cmd="vlc -f ~/anime/[THORA]\ Kemeko\ DX" ;;
        Angel*) cmd="vlc -f ~/anime/Angel\ Beats!" ;;
        GTFO*)
    esac
    
    eval exec $cmd
    the result of the sh file is this Screenshot from 2013-03-02 13:44:44.png

  2. #2
    prodigy_ is offline May the Ubuntu Be With You!
    Join Date
    Mar 2008
    Beans
    1,219

    Re: can someone explain to me this .sh file(uses YAD and zenity)

    Well, lines 1-6 are one huge command that create the GUI dialog and assigns the choice you made to the $action variable. The exit code is assigned to $ret (if you click cancel it'll be 1).

    Code:
    [[ $ret -eq 1 ]] && exit 0 # stop execution and exit if "$ret" equals "1"
    
    if [[ $ret -eq 1 ]]; then # double brackets are redundant, I'd use [ "$ret" -eq "1" ] instead
    vlc ~/Music/Tutturuu~.mp3 # this will never be executed, guess why ;)
     exit 0
    fi
    The case ... esac block basically defines which command will be executed depending on the value stored in $action. Then eval exec $cmd executes the chosen command (stored in $cmd). This is also redundant, could execute right from the case construct.
    Last edited by prodigy_; March 2nd, 2013 at 09:18 PM.

  3. #3
    Join Date
    Jan 2013
    Beans
    29

    Re: can someone explain to me this .sh file(uses YAD and zenity)

    Quote Originally Posted by prodigy_ View Post
    Well, lines 1-6 are one huge command that create the GUI dialog and assigns the choice you made to the $action variable. The exit code is assigned to $ret (if you click cancel it'll be 1).

    Code:
    [[ $ret -eq 1 ]] && exit 0 # stop execution and exit if "$ret" equals "1"
    
    if [[ $ret -eq 1 ]]; then # double brackets are redundant, I'd use [ "$ret" -eq "1" ] instead
    vlc ~/Music/Tutturuu~.mp3 # this will never be executed, guess why ;)
     exit 0
    fi
    The case ... esac block basically defines which command will be executed depending on the value stored in $action. Then eval exec $cmd executes the chosen command (stored in $cmd). This is also redundant, could execute right from the case construct.
    thank you Mr.Prodigy, you have saved my day once more, you are a prodigy indeed

  4. #4
    prodigy_ is offline May the Ubuntu Be With You!
    Join Date
    Mar 2008
    Beans
    1,219

    Re: can someone explain to me this .sh file(uses YAD and zenity)

    You're welcome. :)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •