Results 1 to 8 of 8

Thread: How to make zenity progress-bar actually, well, progress

  1. #1
    Join Date
    Jun 2013
    Location
    Somewhere on Earth.
    Beans
    516
    Distro
    Ubuntu 14.04 Trusty Tahr

    Question How to make zenity progress-bar actually, well, progress

    Hello all!

    I have a couple of commands that I want to run, and I want a zenity progress-bar to integrate to the commands. Unfortunately, I only know how to get the progress-bar to appear, not how to actually make it move. Is there any special way to do this?
    Update: Here are the screenshots.
    Attached Images Attached Images
    Last edited by Jonathan Precise; September 6th, 2013 at 09:09 PM. Reason: --Really-no-signature --Added-indent

  2. #2
    Join Date
    Aug 2013
    Beans
    86
    Distro
    Xubuntu

    Re: How to make zenity progress-bar actually, well, progress

    You advance the bar by piping the value to the command. See https://help.gnome.org/users/zenity/...ogress.html.en

  3. #3
    Join Date
    Oct 2010
    Location
    Above ground...(for now)
    Beans
    761

    Re: How to make zenity progress-bar actually, well, progress

    Here's a working example that keeps the Zenity message box on top using wmctrl.
    if you don't have wmctrl installed, you can comment out the blue line in the code box below:
    Code:
    #!/bin/bash
    
    # Force Zenity Status message box to always be on top.
    sleep 1 && wmctrl -r "Progress Status" -b add,above &
    
    (
    # =================================================================
    echo "# Running First Task." ; sleep 2
    # Command for first task goes on this line.
    
    # =================================================================
    echo "25"
    echo "# Running Second Task." ; sleep 2
    # Command for second task goes on this line.
    
    # =================================================================
    echo "50"
    echo "# Running Third Task." ; sleep 2
    # Command for third task goes on this line.
    
    # =================================================================
    echo "75"
    echo "# Running Fourth Task." ; sleep 2
    # Command for fourth task goes on this line.
    
    
    # =================================================================
    echo "99"
    echo "# Running Fifth Task." ; sleep 2
    # Command for fifth task goes on this line.
    
    # =================================================================
    echo "# All finished." ; sleep 2
    echo "100"
    
    
    ) |
    zenity --progress \
      --title="Progress Status" \
      --text="First Task." \
      --percentage=0 \
      --auto-close \
      --auto-kill
    
    (( $? != 0 )) && zenity --error --text="Error in zenity command."
    
    exit 0
    Last edited by Crusty Old Fart; September 7th, 2013 at 08:46 PM. Reason: Corrected a spelling error.
    Suffering from severe chronic female supervision deficiency syndrome resulting in
    an increasing intolerance of adolescent scatological effluence and PMS induced nefarious diatribe.
    How to: Mark your thread as: [SOLVED]

  4. #4
    Join Date
    Jun 2013
    Location
    Somewhere on Earth.
    Beans
    516
    Distro
    Ubuntu 14.04 Trusty Tahr

    Thumbs up ... Thank you Crusty!

    Quote Originally Posted by Crusty Old Fart View Post
    Here's a working example that keeps the Zenity message box on top using wmctrl.
    if you don' have wmctrl installed, you can comment out the blue line in the code box below:
    Code:
    #!/bin/bash
    
    # Force Zenity Status message box to always be on top.
    sleep 1 && wmctrl -r "Progress Status" -b add,above &
    
    (
    # =================================================================
    echo "# Running First Task." ; sleep 2
    # Command for first task goes on this line.
    
    # =================================================================
    echo "25"
    echo "# Running Second Task." ; sleep 2
    # Command for second task goes on this line.
    
    # =================================================================
    echo "50"
    echo "# Running Third Task." ; sleep 2
    # Command for third task goes on this line.
    
    # =================================================================
    echo "75"
    echo "# Running Fourth Task." ; sleep 2
    # Command for fourth task goes on this line.
    
    
    # =================================================================
    echo "99"
    echo "# Running Fifth Task." ; sleep 2
    # Command for fifth task goes on this line.
    
    # =================================================================
    echo "# All finished." ; sleep 2
    echo "100"
    
    
    ) |
    zenity --progress \
      --title="Progress Status" \
      --text="First Task." \
      --percentage=0 \
      --auto-close \
      --auto-kill
    
    (( $? != 0 )) && zenity --error --text="Error in zenity command."
    
    exit 0
    Thank you for the script!! I adapted it to run maintenance tasks. Here it is:

    Code:
    #!/bin/bash
    
    (
    # =================================================================
    # Configure un-configured packages
    echo "# Doing package maintenance" ; sleep 2
    gksu "gnome-terminal -x dpkg --configure -a"
    
    
    # =================================================================
    # Run Software Updater...
    echo "25"
    echo "# Updating..." ; sleep 2
    update-manager
    
    
    # =================================================================
    # Remove extra programs...
    echo "50"
    echo "# Removing unneeded programs..." ; sleep 2
    gksu "gnome-terminal -x apt-get autoremove"
    
    
    # =================================================================
    echo "75"
    echo "# Finishing..." ; sleep 2
    # Nothing happens here!
    sleep 2
    
    
    # =================================================================
    echo "99"
    echo "# Finishing..." ; sleep 4
    
    
    # =================================================================
    echo "# All finished." ; sleep 2
    echo "100"
    
    
    
    
    ) |
    zenity --progress \
      --title="Simple Maintenance" \
      --text="First Task." \
      --percentage=2 \
      # --pulsate
    
    
    if [ "$?" = -1 ] ; then
            zenity --error \
              --text="Update error."
    fi
    exit 0
    For a pulsating one:

    Code:
    #!/bin/bash
    
    (
    # =================================================================
    echo "# Doing package maintenance" ; sleep 2
    gksu "gnome-terminal -x dpkg --configure -a"
    
    
    # =================================================================
    echo "25"
    echo "# Updating..." ; sleep 2
    update-manager
    
    
    # =================================================================
    echo "50"
    echo "# Removing uneeded programs..." ; sleep 2
    gksu "gnome-terminal -x apt-get autoremove"
    
    
    # =================================================================
    echo "75"
    echo "# Finishing..." ; sleep 2
    # Ignore this line
    sleep 2
    
    
    # =================================================================
    echo "99"
    echo "# Finishing..." ; sleep 4
    
    
    # =================================================================
    echo "# All finished." ; sleep 2
    echo "100"
    
    
    
    
    ) |
    zenity --progress \
      --title="Simple Maintenance" \
      --text="First Task." \
      --percentage=2 \
      --pulsate
    
    
    if [ "$?" = -1 ] ; then
            zenity --error \
              --text="Update error."
    fi
    exit 0
    Thanks again!

    Marked as solved.
    Last edited by Jonathan Precise; September 7th, 2013 at 07:55 PM. Reason: Fixed gksu problem
    -Jonathan
    Status: CELEBRATING 2016!!! (Offline )

  5. #5
    Join Date
    Oct 2010
    Location
    Above ground...(for now)
    Beans
    761

    Code correction.

    Quote Originally Posted by Jonathan Precise View Post
    Thank you for the script!!...
    You're mighty welcome, Jonathan.

    I wrote that script several years ago and have been using it ever since, with success. Consequently, the Zenity error message hasn't appeared. However, after I posted it it here, and saw what the last few lines of the script were, they didn't look right to me. After doing some testing, I found that they really didn't work well. So, I edited my post. Unfortunately, my edit was too late for you to pick up the change. So, I thought I should point out the correction.

    This code doesn't really work right:
    Code:
    if [ "$?" = -1 ] ; then
            zenity --error \
              --text="Update error."
    fi
    exit 0
    It should be replaced with the following:
    Code:
    (( $? != 0 )) && zenity --error --text="Error in zenity command."
    
    exit 0
    Sorry about that.

    Code:
        Thank you for marking your thread as: [SOLVED].
    
                             _---_
                            /_/|\_\
                           (/-O^O-\)
                    __    /_\\/*\//_\    __
             ------vVVv----- o###o -----vVVv------
                              """
    
                       Darthroy was here.
    Suffering from severe chronic female supervision deficiency syndrome resulting in
    an increasing intolerance of adolescent scatological effluence and PMS induced nefarious diatribe.
    How to: Mark your thread as: [SOLVED]

  6. #6
    Join Date
    Aug 2013
    Beans
    86
    Distro
    Xubuntu

    Re: How to make zenity progress-bar actually, well, progress

    That "erroneous" code is straight out of the Gnome example, if you notice.

  7. #7
    Join Date
    Oct 2010
    Location
    Above ground...(for now)
    Beans
    761

    Re: How to make zenity progress-bar actually, well, progress

    Quote Originally Posted by rai_shu2 View Post
    That "erroneous" code is straight out of the Gnome example, if you notice.
    Well, I'll be damned. So, that's where I got it.
    It still sucks, though.
    Suffering from severe chronic female supervision deficiency syndrome resulting in
    an increasing intolerance of adolescent scatological effluence and PMS induced nefarious diatribe.
    How to: Mark your thread as: [SOLVED]

  8. #8
    Join Date
    Jun 2013
    Location
    Somewhere on Earth.
    Beans
    516
    Distro
    Ubuntu 14.04 Trusty Tahr

    Smile Re: Code correction.

    Quote Originally Posted by Crusty Old Fart View Post
    You're mighty welcome, Jonathan.

    I wrote that script several years ago and have been using it ever since, with success. Consequently, the Zenity error message hasn't appeared. However, after I posted it it here, and saw what the last few lines of the script were, they didn't look right to me. After doing some testing, I found that they really didn't work well. So, I edited my post. Unfortunately, my edit was too late for you to pick up the change. So, I thought I should point out the correction.

    This code doesn't really work right:
    Code:
    if [ "$?" = -1 ] ; then
            zenity --error \
              --text="Update error."
    fi
    exit 0
    It should be replaced with the following:
    Code:
    (( $? != 0 )) && zenity --error --text="Update error."
    
    exit 0
    Sorry about that.

    Code:
        Thank you for marking your thread as: [SOLVED].
    Ok. Thank you! I will change that.
    -Jonathan
    Status: CELEBRATING 2016!!! (Offline )

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
  •