views:

228

answers:

4

I need to set myself a reminder to attend a weekly meeting. The trouble with my company's standard reminder tool is that when it runs under wine, it pops up on an off-screen virtual desktop.

I thought it would be interesting to see if I could come up with an "at" command that pops up a reminder window and then resubmits itself for the following week.

I know I could use cron or some alarm-clock app but this piqued my curiosity.

The single-shot version would be:

echo "DISPLAY=$DISPLAY zenity --title='Weekly Meeting' --text='Time for the weekly meeting' --info" | at 0955 NEXT Monday

Can someone come up with a suitable quine-like command that, each time it is run, it will additionally resubmit the same command the following week in a repeating cycle?

+1  A: 

Give this a try:

export reminder='"DISPLAY=$DISPLAY zenity --title='\''Weekly Meeting'\'' --text='\''Time for the weekly meeting'\'' --info" | at 0955 NEXT Monday'; echo $reminder | at 0955 NEXT Monday

Change both at commands to say at now + 1 minute for testing. $DISPLAY will be set when the command is entered and may not be correct at the time the job executes, but this is the same behavior as the command in your question.

Dennis Williamson
This doesn't do it: what it executes next Monday is another "at" command to run zenity the following Monday.
Adrian Pronk
Oops, I forgot to take out an extra `echo`. Try the edited version.
Dennis Williamson
A: 

Try with a file:

$ cat /tmp/quine_file
DISPLAY=:0.0 zenity --title='Weekly Meeting' --text='Time for the weekly meeting' --info;
at '0955 NEXT monday' </tmp/quine_file;

$ at '0955 NEXT monday' </tmp/quine_file

This way, every time the job is run, another one is scheduled for next monday.

marco
That's what I did in the end. But I'd still like to try and get a solution without using a file like this.
Adrian Pronk
A: 

I'm probably cheating, but you can take advantage of the fact that at conserves the value of most environment variables (not $DISPLAY though, neither $DISP it seems):

export FOO=$DISPLAY CMD='DISPLAY=$FOO xmessage "hi there";
echo "$CMD" | at now + 1 minutes'
eval "$CMD"

I used xmessage and one minute because I had them, but of course you can tailor it to your needs.

Jérémie Koenig
That runs it twice. But it doesn't reschedule itself.
Dennis Williamson
I guess your `at` must differ from mine somehow. Does adding `export FOO CMD;` before `echo` fix the problem?
Jérémie Koenig
A: 

Sorry to spoil the fun, but... wouldn't some sort of cron job make more sense?

SamB
-1: Did you see the "fun" tag? I know how to use a cron job so I don't need to ask on SO about that. What I don't know is how to make a quine-like shell script. Hence this question.
Adrian Pronk