Providing feedback in scripts - Tip
Posted: Sat 08 Oct 2005, 01:06
This is not cutting edge, but it's development and it didn't fit anywhere else.
I've seen that Barry's scripts execute the 'please wait..' xmessage before doing something time consuming.
The problem I saw is that the script "killall xmessage" will kill other scripts with xmessage windows open.
I found this while looking for a way to provide feedback in my vncserver-wizard. So I saw how Barry was doing it and took the idea one step further to only close the window I want to close. Here is the generic form:
or
I've seen that Barry's scripts execute the 'please wait..' xmessage before doing something time consuming.
The problem I saw is that the script "killall xmessage" will kill other scripts with xmessage windows open.
I found this while looking for a way to provide feedback in my vncserver-wizard. So I saw how Barry was doing it and took the idea one step further to only close the window I want to close. Here is the generic form:
Code: Select all
# Show the wait message
xmessage -bg "#b3bfab" -center -name "wait" -title "A title" \
-buttons "" "Doing something. Please wait ..." & echo $! > /tmp/msg1PID
# Do some task that takes some time
dosomething
# Kill the window we started abobe
kill `cat /tmp/msg1PID`
Code: Select all
# Show the wait message
xmessage -bg "#b3bfab" -center -name "wait" -title "A title" \
-buttons "" "Doing something. Please wait ..." &
# Save the window's process ID
MSG_PID=$!
# Do some task that takes some time
dosomething
# By killing the process we in fact close the window
kill $MSG_PID