Skip to content

Instantly share code, notes, and snippets.

@ryran
Created July 18, 2013 14:25
Show Gist options
  • Save ryran/6029772 to your computer and use it in GitHub Desktop.
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
#!/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