I need a progress bar for a function in my bash script.
How can I do this with Xdialog or gtk-dialog?
Code: Select all
myfunction () {
...
...
}
myfunction
Code: Select all
myfunction () {
...
...
}
myfunction
You could check out project pmusiclinus.cl wrote: I need a progress bar for a function in my bash script.
How can I do this with Xdialog or gtk-dialog?
Code: Select all
#!/bin/sh
rm -f /tmp/f
mkfifo /tmp/f
sleep 1000000 > /tmp/f &
SLEEPER=$!
Xdialog --gauge "original text" 0 0 < /tmp/f &
XPID=$!
out() {
kill -0 $XPID 2>/dev/null &&
echo "$1" > /tmp/f
}
newtext() {
out XXX
out "$1"
out XXX
}
### main
sleep 1 # just to show original text
for p in $(seq 0 10 100); do
out $p
newtext "progress now at $p%"
sleep 1
done
# cleanup
kill $SLEEPER
rm -f /tmp/f