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 Tue 30 Jun 2015, 10:37
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 Posts_count  
Author Message
linus.cl

Joined: 02 Apr 2014
Posts: 101
Location: Germany

PostPosted: Wed 24 Sep 2014, 09:16    Post_subject:  Xdialog or gtk-dialog progress bar for functions (bash)
Sub_title: 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: 418

PostPosted: Wed 24 Sep 2014, 09:51    Post_subject: Re: Xdialog or gtk-dialog progress bar for functions (bash)
Sub_title: 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: 2465
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: 101
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:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


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