Can you write a simple weekly reminder using a bash/sh script quine?
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?
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
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.
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.
I’m probably cheating, but you can take advantage of the fact that
at conserves the value of most environment variables
$DISPLAY though, neither
$DISP it seems):
export FOO=$DISPLAY CMD='DISPLAY=$FOO xmessage "hi there"; echo "$CMD" | at now + 1 minutes' eval "$CMD"
xmessage and one minute because I had them,
but of course you can tailor it to your needs.
Sorry to spoil the fun, but… wouldn’t some sort of cron job make more sense?
- Database Administration Tutorials
- Programming Tutorials & IT News
- Linux & DevOps World
- Ebook Reviews
- PES Matches, Skills & News