Simple reminders using a bash script

I often get engrossed in work and forget things like picking the kids up from the bus stop. There are loads of utilitiesthat provide reminders but they all involve opening an application or editing a file. By the time I've made time to do that I've often forgotten what I'm supposed to be reminding myself about.

I need to quickly enter my reminders at the command line while I'm on the phone or doing other things so I'll write a script to do it. Skip to the end if you just want the script. Here's how I created it:

There are three commands that can be combined to do what I want.

  • The command at takes a nice flexible time specification (17:00, 5pm, 9am 2 Dec, now + 10 minutes... use man at for details but reasonable guesses usually work). at will execute any command you enter at the specified time.
  • The command notify-send (install libnotify-bin if this command is not already on your system) displays an alert window.
  • aplay will play a sound.
First I have a play at the command line:
~ $ at now + 1 minutes
warning: commands will be executed using /bin/sh
at> notify-send  "Reminder" "Finish atr script"
at> aplay -q /usr/share/sounds/question.wav
at> <EOT>
job 3 at Wed Nov 25 08:42:00 2009

This does the trick nicely popping up the required message and playing the sound but its easy to get wrong so I'll create a script "atr" (short for 'at reminder') to make it easier. I want my script to be like this:

~ $ atr now + 1 minutes = Boo
~ $ atr 16:00 = Pick up boys
~ $ atr 16:00 + 1 day = Pick up boys
~ $ atr 1pm = have lunch

I want to hide the notify and at complexity so the '=' sign is just breaking up what goes to at and the message that goes to notify-send. Here we go:

#!/bin/bash
# Nice reminders -
# take input line and break it at = supplying the args before the =
# to 'at' and the message after the = to 'notify-send'
# Examples
# remind 16:00 = Pick up boys
# remind 16:00 + 1 day = Pick up boys
# remind 17:00 2 Dec = SVBN dinner
# 
ALLARGS="$@"
MESSAGE=${ALLARGS##*=}
ATARGS=${ALLARGS%%=*}

at $ATARGS << EOF
notify-send  -t 500 "Reminder" "$MESSAGE"
aplay -q /usr/share/sounds/question.wav
EOF

I can use the command atq to check that a reminder is in the queue and remove them if necessary using atrm so its all done for my simple reminder. I can type simple reminders at the command line without needing to open calendars or any such thing. Perhaps I'll enhance it to send me an SMS too one day then I'm covered if I'm not at my machine.


Comments

ghostDancer 6 years, 2 months ago

Thanks for the script
I was looking for something similar but my bash-fu is not good (well i really don't have). Really useful. Thanks.

Link | Reply

New Comment

required

required (not published)

optional

Australia: 07 3103 2894

International: +61 410 545 357