Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 01 Oct 2014, 02:10
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Xdialog or gtk-dialog progress bar for functions (bash)
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [4 Posts]  
Author Message
linus.cl

Joined: 02 Apr 2014
Posts: 79
Location: Germany

PostPosted: Wed 24 Sep 2014, 09:16    Post subject:  Xdialog or gtk-dialog progress bar for functions (bash)
Subject description: How can I add a progress bar to my script
 

Hello!

I need a progress bar for a function in my bash script.
How can I do this with Xdialog or gtk-dialog?

Code:

myfunction () {
  ...
  ...
}
myfunction


Thank you!
Back to top
View user's profile Send private message 
Scooby

Joined: 03 Mar 2012
Posts: 312

PostPosted: Wed 24 Sep 2014, 09:51    Post subject: Re: Xdialog or gtk-dialog progress bar for functions (bash)
Subject description: How can I add a progress bar to my script
 

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.
Back to top
View user's profile Send private message 
jamesbond

Joined: 26 Feb 2007
Posts: 2184
Location: The Blue Marble

PostPosted: Wed 24 Sep 2014, 13:59    Post subject:  

Code:
#!/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, Slacko and Puppeee user. Puppy user since 2.13.
Contributed Fatdog64 packages thread
Back to top
View user's profile Send private message 
linus.cl

Joined: 02 Apr 2014
Posts: 79
Location: Germany

PostPosted: Thu 25 Sep 2014, 10:58    Post subject:  

Thank you, jamesbond!

It is working now!
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0441s ][ Queries: 11 (0.0034s) ][ GZIP on ]