Countdown in xmessage possible?
am 26.11.2007 06:09:52 von 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?
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
Re: Countdown in xmessage possible?
am 26.11.2007 18:07:17 von gazelle
In article <13kkl90psad8995@corp.supernews.com>,
Portsample wrote:
>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.
>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
Re: Countdown in xmessage possible?
am 27.11.2007 15:46:28 von Christian Gollwitzer
Kenny McCormack schrieb:
> Portsample wrote:
>> 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...