1

I have a simple app with some bash command, for example apt update, and I want to pipe its output to --text parameter in zenity Progress dialog , i tried some options after googling like :

gksudo apt update | xargs -L1 -I % zenity --progress --text=% --percentage=0 --auto-close --auto-kill 

but all i got is blinking window!

So, how can i make the output appearing in zenity window with progress percentage?

Hayder Ctee
  • 145
  • 9

1 Answers1

1

You cannot make the output appearing in zenity window with progress percentage, because for a percentage computation the information what amounts to 100 % is needed, and here it is not known beforehand how much output the apt update command will generate.

What you can do is have an animated progress bar while apt update is outputting something. Since standard output to a pipe is normally fully buffered, the buffering has to be changed with stdbuf:

gksudo stdbuf -oL apt update | zenity --progress --pulsate --auto-close --auto-kill
Armali
  • 18,255
  • 14
  • 57
  • 171
  • 2
    In theory you could compute the current progress from `apt update`'s output by checking how many of the URLs from `apt-cache policy` got checked so far. However, showing the output of `apt update` (missing here) might only be possible *after* the command finished, so there is no point in a progress bar. – Socowi Feb 21 '19 at 19:13