3

I know that I can change the progress of a whiptail --gauge using something like:

{
    for ((i = 0 ; i <= 100 ; i+=20)); do
        sleep 1
        echo $i
    done
} | whiptail --gauge "Please wait while installing" 6 60 0

But I am wondering whether it is possible to edit/modify the text of the whiptail box (so change the Please wait while installing text to something else.

My current solution is to bring up a new whiptail box, but there is a noticeable flicker between the old one closing and the new one opening. If you can't update the text of a whiptail box, is it possible to reduce/remove this flicker instead?

user2370460
  • 183
  • 2
  • 6

2 Answers2

6

Try this:

#!/bin/bash

msgs=( "Downloading" "Verifying" "Unpacking" "Almost Done" "Done" )

for i in {1..5}; do
  sleep 1
  echo XXX
  echo $(( i * 20 ))
  echo ${msgs[i-1]}
  echo XXX
done |whiptail --gauge "Please wait while installing" 6 60 0
adonis
  • 1,714
  • 9
  • 9
1

The flicker comes from (a) switching to/from the alternate/normal screens in the terminal and (b) from clearing the display.

You can eliminate the first part by choosing a terminal description lacking the control sequences used for switching between normal/alternate screens. Usually those are the smcup and rmcup capabilities in the terminal description, so...

infocmp >foo
vi
...remove the assignments to `rmcup` and `smcup`
tic foo
...with ncurses, that likely creates an entry in `$HOME/.terminfo`

dialog handles this by optionally suppressing those capabilities (i.e., --keep-tite); whiptail doesn't know anything about the alternate screen.

Further reading:

Thomas Dickey
  • 75,040
  • 9
  • 171
  • 268