|
@@ -72,15 +72,32 @@ if [ "${ISKDE}" != "" -o "${ZENITY}" = "" ]; then
|
72
|
72
|
if [ "${USEDCOP}" != "" -a "${DCOP}" != "" ]; then
|
73
|
73
|
KDETYPE="dcop"
|
74
|
74
|
USEKDIALOG="1";
|
75
|
|
- else if [ "${USEDCOP}" = "" -a "${QDBUS}" != "" ]; then
|
|
75
|
+ elif [ "${USEDCOP}" = "" -a "${QDBUS}" != "" ]; then
|
76
|
76
|
KDETYPE="qdbus"
|
77
|
77
|
USEKDIALOG="1";
|
78
|
|
- else if [ "${USEDCOP}" = "" -a "${DBUSSEND}" != "" ]; then
|
|
78
|
+ elif [ "${USEDCOP}" = "" -a "${DBUSSEND}" != "" ]; then
|
79
|
79
|
KDETYPE="dbussend"
|
80
|
80
|
USEKDIALOG="1";
|
81
|
81
|
fi;
|
82
|
82
|
fi;
|
83
|
83
|
|
|
84
|
+# Check for special watchdog mode.
|
|
85
|
+# In this mode we are used to kill ourself after a certain time limit to make sure we don't hang.
|
|
86
|
+if [ "${1}" == "--watchdog" ]; then
|
|
87
|
+ if [ "" != "${2}" ]; then
|
|
88
|
+ echo "Watchdog for: ${2}"
|
|
89
|
+ sleep 5;
|
|
90
|
+ kill -1 ${2} >/dev/null 2>&1 &
|
|
91
|
+ sleep 5;
|
|
92
|
+ kill -9 ${2} >/dev/null 2>&1 &
|
|
93
|
+ exit 0;
|
|
94
|
+ else
|
|
95
|
+ echo "No PID specified to watch."
|
|
96
|
+ exit 1;
|
|
97
|
+ fi;
|
|
98
|
+
|
|
99
|
+ exit 1;
|
|
100
|
+fi;
|
84
|
101
|
|
85
|
102
|
CAPTION=${1}
|
86
|
103
|
FILESIZE=${2}
|
|
@@ -124,7 +141,7 @@ readprogress() {
|
124
|
141
|
${DCOP} ${progresswindow} setProgress ${val}
|
125
|
142
|
returnVal=${?}
|
126
|
143
|
elif [ "${KDETYPE}" = "qdbus" ]; then
|
127
|
|
- ${QDBUS} ${progresswindow} org.freedesktop.DBus.Properties.Set org.kde.kdialog.ProgressDialog value 20
|
|
144
|
+ ${QDBUS} ${progresswindow} org.freedesktop.DBus.Properties.Set org.kde.kdialog.ProgressDialog value ${val}
|
128
|
145
|
returnVal=${?}
|
129
|
146
|
elif [ "${KDETYPE}" = "dbussend" ]; then
|
130
|
147
|
${DBUSSEND} --print-reply --dest=${progresswindow} org.freedesktop.DBus.Properties.Set string:'org.kde.kdialog.ProgressDialog' string:'value' variant:int32:${val} > /dev/null
|
|
@@ -153,7 +170,7 @@ readprogress() {
|
153
|
170
|
done;
|
154
|
171
|
}
|
155
|
172
|
|
156
|
|
-if [ "" = "${CAPTION}" -o "" = ${FILESIZE} ]; then
|
|
173
|
+if [ "" = "${CAPTION}" -o "" = "${FILESIZE}" ]; then
|
157
|
174
|
echo "Insufficient Parameters."
|
158
|
175
|
echo "Usage: ${0} <caption> <totalvalue> [pipename]"
|
159
|
176
|
exit;
|
|
@@ -173,17 +190,47 @@ fi;
|
173
|
190
|
|
174
|
191
|
echo "Using pipe: "${PIPE}
|
175
|
192
|
mkfifo "${PIPE}"
|
|
193
|
+EMPTYPIPE="1"
|
|
194
|
+WDPID=""
|
|
195
|
+WD2PID=""
|
176
|
196
|
closeProgress() {
|
177
|
197
|
CONTINUE="0"
|
178
|
198
|
if [ "${TYPE}" = "KDE" -a ${retval} != "0" ]; then
|
179
|
|
- dcop ${progresswindow} close
|
|
199
|
+ if [ "${KDETYPE}" = "dcop" ]; then
|
|
200
|
+ ${DCOP} ${progresswindow} close
|
|
201
|
+ elif [ "${KDETYPE}" = "qdbus" ]; then
|
|
202
|
+ ${QDBUS} ${progresswindow} org.kde.kdialog.ProgressDialog.close
|
|
203
|
+ elif [ "${KDETYPE}" = "dbussend" ]; then
|
|
204
|
+ ${DBUSSEND} --print-reply --dest=${progresswindow} org.kde.kdialog.ProgressDialog.close > /dev/null
|
|
205
|
+ fi;
|
180
|
206
|
fi;
|
181
|
207
|
echo "Exiting with value: $retval"
|
182
|
|
- if [ -e ${PIPE} ]; then
|
|
208
|
+ if [ "${WGETPID}" != "" ]; then
|
183
|
209
|
echo "Attempting to kill wget"
|
184
|
210
|
kill -9 ${WGETPID}
|
185
|
|
- echo "Emptying pipe"
|
186
|
|
- cat ${PIPE};
|
|
211
|
+ fi;
|
|
212
|
+
|
|
213
|
+ if [ -e ${PIPE} ]; then
|
|
214
|
+ if [ "${EMPTYPIPE}" = "1" ]; then
|
|
215
|
+ sh ${0} --watchdog ${$} &
|
|
216
|
+ WDPID=${!}
|
|
217
|
+
|
|
218
|
+ EMPTYPIPE="2"
|
|
219
|
+ echo "Emptying pipe (${PIPE}) this may hang if no data has been written to the pipe."
|
|
220
|
+ cat ${PIPE};
|
|
221
|
+ elif [ "${EMPTYPIPE}" = "2" ]; then
|
|
222
|
+ echo "Helping pipe (${PIPE}) this may hang if nothing is reading from the pipe."
|
|
223
|
+ sh ${0} --watchdog ${$} &
|
|
224
|
+ WD2PID=${!}
|
|
225
|
+ EMPTYPIPE="3"
|
|
226
|
+ echo "." > ${PIPE};
|
|
227
|
+ else
|
|
228
|
+ echo "Ignoring Pipe..."
|
|
229
|
+ fi;
|
|
230
|
+ echo "Killing watchdog 1."
|
|
231
|
+ kill -9 ${WDPID}
|
|
232
|
+ echo "Killing watchdog 2."
|
|
233
|
+ kill -9 ${WD2PID}
|
187
|
234
|
echo "Deleting Pipe ${PIPE}"
|
188
|
235
|
rm -Rf "${PIPE}"
|
189
|
236
|
fi;
|
|
@@ -191,6 +238,7 @@ closeProgress() {
|
191
|
238
|
}
|
192
|
239
|
trap 'closeProgress' INT TERM EXIT
|
193
|
240
|
|
|
241
|
+
|
194
|
242
|
# if kdialog exists, and we have a display, and we are not running gnome,
|
195
|
243
|
# and either we are running kde or zenity doesn't exist..
|
196
|
244
|
if [ "" != "${KDIALOG}" -a "" != "${DISPLAY}" -a "" = "${ISGNOME}" -a "${USEKDIALOG}" = "1" ]; then
|