このコードを.codewget + zenity
から移植しようとしています。wget + kdialog
zenity
#!/bin/bash
# Start wget | zenity
# Note the & at the end of the pipe, this allows the script to continue with wget running in the background
wget http://www.zezeniaonline.com/download/downloadlinux 2>&1 | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9.]\+.\) \(.*\)/\1\n# Downloading at \2\/s, ETA \3/' | zenity --progress --title="Downloading File..."
#Start a loop testing if zenity is running, and if not kill wget
RUNNING=0
while [ $RUNNING -eq 0 ]
do
if [ -z "$(pidof zenity)" ]
then
pkill wget
RUNNING=1
fi
done
Zenityコードは完璧に動作します
同じことをする必要がありましたがkdialog
。
#!/bin/bash
# Start wget | kdialog
wget http://www.zezeniaonline.com/download/downloadlinux 2>&1 | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9.]\+.\) \(.*\)/\1\n# Downloading at \2\/s, ETA \3/' | kdialog --progressbar " " --title="Downloading File..."
#Start a loop testing if zenity is running, and if not kill wget
RUNNING=0
while [ $RUNNING -eq 0 ]
do
if [ -z "$(pidof kdialog)" ]
then
pkill wget
RUNNING=1
fi
done
まったく動作しません
#!/bin/bash
# Start wget | kdialog
wget --progress=dot http://www.zezeniaonline.com/download/downloadlinux 2>&1 | fgrep --line-buffered '%' \ | sed -u -r 's:.* ([0-9]+)% .*:\1:' | kdialog --title "Installation" --progressbar " " &
#Start a loop testing if kdialog is running, and if not kill wget
RUNNING=0
while [ $RUNNING -eq 0 ]
do
if [ -z "$(pidof kdialog)" ]
then
pkill wget
RUNNING=1
fi
done
ところで、以下のようなエラーが発生します。 はい、ダウンロードしていますが、「kdialog」の「進行」は「進行」ではありません。
ベストアンサー1
以下は、このページにリンクされているサイトのいくつかの以前のチュートリアルで修正された私のソリューションです。
このコードはgithubのデフォルトリポジトリをダウンロードしようとします。
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 "KILLING THE PROCESS AND KDIALOG"
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 }')