Originally Posted by
Crusty Old Fart
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.
Bookmarks