Created
July 18, 2013 14:25
-
-
Save ryran/6029772 to your computer and use it in GitHub Desktop.
A simple example of using the coprocessor feature of bash -- in this case, to launch a GUI progress bar via zenity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Start Zenity (might not be installed by default) as a bash coprocess | |
coproc zenity --progress --pulsate --title='Testing' --text='Starting up...' | |
z1=${COPROC[1]} | |
# Update Zenity... | |
sleep 2s | |
echo 33 >&$z1 | |
echo '#One third done...' >&$z1 | |
sleep 2s | |
echo 67 >&$z1 | |
echo '#Two thirds done...' >&$z1 | |
sleep 2s | |
echo 100 >&$z1 # Close Zenity and therefore the background task. | |
echo '#Finished!' >&$z1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment