say I have the following script (let's posit pv and curl are already installed) :

(that currently runs under ubuntu but that I plan to make POSIX-compliant so that it may run on more linux ditributions)

sudo apt install vlc
mkdir -p ~/.steam/compatibilitytools.d
PROTONVERSIONNUMBER=$(curl -v --silent https://api.github.com/repos/popsUlfr/Proton/releases 2>&1 | grep "tag_name" | head -n 1 | cut -f4,4 -d"\"")
REPLACING=$(curl -v --silent https://api.github.com/repos/popsUlfr/Proton/releases 2>&1 | grep "target_commitish" | head -n 1 | cut -f4,4 -d"\"" | sed "s/[^_]\+/\L\u&/g")
wget https://github.com/popsUlfr/Proton/releases/download/$PROTONVERSIONNUMBER/$PROTONNAME.tar.xz
pv $PROTONNAME.tar.xz | tar xp -J -C ~/.steam/compatibilitytools.d
rm $PROTONNAME.tar.xz

I get three progress bars, these progress bars seem very beautiful to me :

the way they're accurate and stuff, I dunno call me a weirdo


How do I utilize the power of these three seperate progress bars to form one continuous progress bar that respects currents progress bar "speeds" of the underlying "true" progress bars?

  • You mention some concerns about the availability of pv, but do not seem to have the same concerns regarding the availability of whiptail, apt, bash, sudo, or wget. Do you have portability constraints at all? What does your "every OS" mean? – Kusalananda Mar 8 '19 at 10:38
  • well ok my script is actually more robust then the barebones example above, I actually have a huge if else going over almost all possible linux distros and later down case switches change for example sudo and apt to their equivalents. maybe I should edit my post to specify that I intend for it to work on all distros but start by getting it to work on ubuntu first, for which whiptail and wget comes prepakaged but pv not. That being said I haven't entirely excluded working with pv, it seems quite powerfull and might be worth a temporary install as part of the script. – tatsu Mar 8 '19 at 10:44

Here is a sample piece of code that demonstrates how you can have multiple sections of "work" all updating the same progress meter. The Whiptail gauge is attached to the script's file descriptor 3, so that it can be updated at any point during the script. (The gauge exits automatically when the script ends, or when FD 3 is explicitly closed.)


    # Clean up when we're done
    exec 3>&-
    [[ -n "$tmpd" ]] && rm -rf "$tmpd"
trap 'ss=$?; tidyUp; exit $ss' 1 2 15

    local percent="$1" message="$2"
    printf "XXX\n%d\n%s\nXXX\n" $percent "$message" >&3

# Create the FIFO for communicating with the whiptail gauge
tmpd=$(mktemp --tmpdir --directory "wt.XXXXXXXXXX")
mkfifo "$tmpd/fifo"

# Start up the whiptail gauge and associate FD 3 with its status
whiptail --title 'Progress meter' --gauge 'Starting examples' 6 50 0 <"$tmpd/fifo" &
exec 3>"$tmpd/fifo"

# Real code starts here

for example in 1 2 3
    updateGauge $percent "Getting example $example"
    sleep 3    # wget something

    percent=$((percent + 20))

for another in 4 5
    updateGauge $percent "Doing work for another example $another"
    sleep 2    # do some work

    percent=$((percent + 20))

# Done
exit 0
| improve this answer | |
  • that's a no, there are two problems with this, one, the bar doesn't move between steps, the point of my question was "how could I benefit from existing progress bars?" not "how could I disregard them?" the second issue is that while you do get to see wget's progress bar on top, the display is broken : imgur.com/Q7Wod9N and either way I'm sure whiptail's intended behavior is to only have whiptail visible. I think i'll try with pv instead. – tatsu Mar 8 '19 at 12:40
  • 1. As written it does move between steps. If it doesn't work for you, how are you calling it? – roaima Mar 8 '19 at 12:47
  • 1
    2. You'd run wget -q so that the whiptail progress meter was the only thing showing. I addressed your seemingly fundamental "all I want is to have a progress bar present from start to finish of my script". Pretty definite to me. – roaima Mar 8 '19 at 12:49
  • I dunno you try it : pastebin.com/2YZRgu4B I get visual glitching all over the terminal console, it's impossible to see what's going on. – tatsu Mar 8 '19 at 12:57
  • here's a new version where I fixed the extra outputs : pastebin.com/ikrp7AN2 as you can see, the progress bar of whiptail jumps from 0 to 20 ect... i can see why if I remove pv from the tar opperation whiptail would have nothing to go off of but for the wget it has no progress either – tatsu Mar 8 '19 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.