Search code examples
linuxbashzenity

How To Piped Terminal Command Output To Zenity Progress Dialog Text?


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?


Solution

  • 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