kdialog qdbus progress bar


if you have a brain you should understand this and how it works :

sudo apt-get install qt4-dev-tools #for qdbusviewer so you can undestand a bit qdbus & kdialog

mystufvariabletouseonmyscript=$(kdialog --progressbar "hello this is a progress bar with 100 steps" 100) ; sleep 2 ; qdbus $mystufvariabletouseonmyscript org.kde.kdialog.ProgressDialog.setLabelText "omg i have changed text" ; sleep 2 ; qdbus $mystufvariabletouseonmyscript showCancelButton true ;qdbus $mystufvariabletouseonmyscript org.kde.kdialog.ProgressDialog.setLabelText "omg now there is cancel button" ;sleep 2; qdbus $mystufvariabletouseonmyscript Set org.kde.kdialog.ProgressDialog value 30 && qdbus $mystufvariabletouseonmyscript org.kde.kdialog.ProgressDialog.setLabelText "omg i have change the value";sleep 2 ; qdbus $mystufvariabletouseonmyscript Set org.kde.kdialog.ProgressDialog value 0 ;qdbus $mystufvariabletouseonmyscript org.kde.kdialog.ProgressDialog.setLabelText "Now you can click on the cancel button to stop a process" ;until test "true" = `qdbus $mystufvariabletouseonmyscript wasCancelled` ; do sleep 1 ; inc=$((`qdbus $mystufvariabletouseonmyscript Get "" "value"`+1)); qdbus $mystufvariabletouseonmyscript Set org.kde.kdialog.ProgressDialog value $inc; done

an example with youtube-dl that is pretty nasty , this example was prepared with the big help of Vincenzo Tibullo

a=$(kdialog --progressbar "YouTube-dl will download the file" 100);sleep 2 ; while read line ; do qdbus $a Set org.kde.kdialog.ProgressDialog value $line ; done < <(youtube-dl -t "http://www.youtube.com/watch?v=5Lv8eksIoRg&list=UUraFXVifKFyN66mtTP67ZwQ&index=1" |stdbuf -o0 tr '\r' '\n' |mawk -W interactive '{ print int($2+0) }')

an example with wget

ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"31;01m"
COL_GREEN=$ESC_SEQ"32;01m"
COL_YELLOW=$ESC_SEQ"33;01m"
COL_BLUE=$ESC_SEQ"34;01m"
COL_MAGENTA=$ESC_SEQ"35;01m"
COL_CYAN=$ESC_SEQ"36;01m"

link="https://github.com/nowardev/kde-peace-settings/archive/master.zip" #my own github stuff 
a=$(kdialog --progressbar "W-Get will  download: Nowardev GitHub Master stuff " 100);sleep 2
qdbus $a  showCancelButton true

while read line ;do
read -r p t <<< "$line"
echo $p 
echo $t 
qdbus $a Set org.kde.kdialog.ProgressDialog value $p

	while [[  $(qdbus  $a wasCancelled) != "false" ]] ; do
		echo -e " $COL_RED  THE PROCESS AND KDIALOG COL_RESET "
		qdbus $a  org.kde.kdialog.ProgressDialog.close 
		
		exit
	done
			

qdbus $a org.kde.kdialog.ProgressDialog.setLabelText "W-Get will  download: Nowardev GitHub Master stuff  time left : $t" 


done< <(wget "$link" 2>&1 |mawk -W interactive '{ gsub(/\%/," "); print int($7)" "$9 }')

and example with axel

a=$(kdialog --progressbar "Axel  will  download: Kubuntu 14.10 32 bit " 100);sleep 2 ; qdbus $a  showCancelButton true; while read line ; do while [[  $(qdbus  $a wasCancelled) != "false"  ]] ; do echo -e "$COL_RED ECHO KILLING AXEL AND KDIALOG $COL_RESET" ; qdbus $a  org.kde.kdialog.ProgressDialog.close ; exit ;done ; if [[ $lineold != $line ]]; then qdbus $a Set org.kde.kdialog.ProgressDialog value $line ; fi ;  lineold=$line ; done  < <( axel -n 10 http://cdimage.ubuntu.com/kubuntu/daily-live/current/vivid-desktop-i386.iso | mawk -W interactive  -F']' '{gsub(/ /,"");gsub(/\[/,"");gsub(/\%/,"");print $1}') 

3 Responses to kdialog qdbus progress bar

  1. Inukaze says:

    Hi there , i really need an example using “wget $url”

    Because i dont know how works the youtube-dl

    im trying to make a script with kdialog , with a download progress , but nothing i test works how i need it.

    Can you make an example with “wget” , please ?

  2. Pingback: Unix:Bash Script – Wget Graphical Download Progress – Unix Questions

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: