Discussion:
Countdown in xmessage possible?
(too old to reply)
Portsample
2007-11-26 05:09:52 UTC
Permalink
Hey all,

I've written a little script that I run via cron job to close down my
mail reader at the end of the day. I would like add a 30 second countdown
to the xmessage popup. Is there an easy way to do this?

Below is my script so far minus the timer. Thanks.

#!/bin/sh
DISPLAY=:0.0 xmessage \
-center\
-title WARNING \
-timeout 15 \
-buttons AbortShutdown:3,Shutdown:2 -default Shutdown \
" Evolution mail reader will shutdown in 90 seconds. "\

case $? in
0) exit 0 ;; #"0" returned if xmessage timeout
1) exit 0 ;; #"1" returned if xmessage window is closed

2) DISPLAY=:0.0 xmessage -button "" -timeout 1 -center
"EVOLUTION closing now." && evolution --force-shutdown && exit 0;;

3) DISPLAY=:0.0 xmessage -button "" -timeout 1 -center
"EVOLUTION shutdown stopped" && exit 0;;

*) break ;;# ...covers "other" returned values, (Exceptions)
esac
exit 0
Kenny McCormack
2007-11-26 17:07:17 UTC
Permalink
Post by Portsample
Hey all,
I've written a little script that I run via cron job to close down my
mail reader at the end of the day. I would like add a 30 second countdown
to the xmessage popup. Is there an easy way to do this?
I don't think it is possible in xmessage - I've been using xmessage for
several years now, and have never seen anything in the documentation to
suggest that this is possible.

This does sound like a nifty thing to do, though, and I'd be interested
in seeing if we can't come up with something. My guess is that we'll
have to write something in Tcl/TK. I did some TK years ago, but haven't
done anything lately. I keep meaning to pick it up again and try some
things.
Post by Portsample
Below is my script so far minus the timer. Thanks.
#!/bin/sh
DISPLAY=:0.0 xmessage \
-center\
-title WARNING \
-timeout 15 \
-buttons AbortShutdown:3,Shutdown:2 -default Shutdown \
" Evolution mail reader will shutdown in 90 seconds. "\
case $? in
0) exit 0 ;; #"0" returned if xmessage timeout
1) exit 0 ;; #"1" returned if xmessage window is closed
2) DISPLAY=:0.0 xmessage -button "" -timeout 1 -center
"EVOLUTION closing now." && evolution --force-shutdown && exit 0;;
3) DISPLAY=:0.0 xmessage -button "" -timeout 1 -center
"EVOLUTION shutdown stopped" && exit 0;;
*) break ;;# ...covers "other" returned values, (Exceptions)
esac
exit 0
Christian Gollwitzer
2007-11-27 14:46:28 UTC
Permalink
Post by Kenny McCormack
Post by Portsample
I've written a little script that I run via cron job to close down my
mail reader at the end of the day. I would like add a 30 second countdown
to the xmessage popup. Is there an easy way to do this?
This does sound like a nifty thing to do, though, and I'd be interested
in seeing if we can't come up with something. My guess is that we'll
have to write something in Tcl/TK.
in Tcl/Tk thats very easy to do. As a starting point, try


#####################
package require Tk
label .text
button .ok -text "OK" -command fire
pack .text .ok
set countdown 30
set warning "The system will go down in %d seconds"

proc countdown {} {
global warning countdown
.text conf -text [format $warning $countdown]
if {$countdown<=0} fire
incr countdown -1
after 1000 countdown
}

proc fire {} {
exit
}

countdown
##################

replace the fire command by anything you like...

Loading...