Xdialog or gtk-dialog progress bar for functions (bash)

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
linus.cl
Posts: 126
Joined: Wed 02 Apr 2014, 14:09
Location: Germany
Contact:

Xdialog or gtk-dialog progress bar for functions (bash)

#1 Post by linus.cl »

Hello!

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
Thank you!

Scooby
Posts: 599
Joined: Sat 03 Mar 2012, 09:04

Re: Xdialog or gtk-dialog progress bar for functions (bash)

#2 Post by Scooby »

linus.cl wrote: I need a progress bar for a function in my bash script.
How can I do this with Xdialog or gtk-dialog?
You could check out project pmusic

it includes pmusic-4.4.1/usr/local/pmusic/box_progress

Which can be used as a model for a progressbar in gtkdialog.

I believe you have to yourself calculate the progress increments.

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#3 Post by jamesbond »

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
Enjoy.
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

linus.cl
Posts: 126
Joined: Wed 02 Apr 2014, 14:09
Location: Germany
Contact:

#4 Post by linus.cl »

Thank you, jamesbond!

It is working now!

Post Reply