This is a script I use so I don't forget my appointments, even when I forget to check remind or wyrd. It returns the next appointment from a reminders file and tries to output it in a nice way. I use it to populate a textwidget in my awesome wibox so my next appointment is always on the screen.
Dependencies
Usage
The script is called with no arguments, everything is set in the configurables. You just configure the reminders file it should use and the months it should check ahead. When called, the script returns the next appointment, or the current one if one is in progress in the following manner:
Next appointment:
user@host ~> bash Scripts/reminderwidget 2011/08/25 10:00-12:00 Structured computer organization
When one is already in progress:
user@host ~> bash Scripts/reminderwidget NOW: 08:00-10:00 Important
talk I really should attend
The script
#!/bin/bash #Configurables: MONTHSTOCHECKAHEAD=12 REMINDERSFILE=/home/USERNAME/.reminders #Helper function to check if a date is in the future is_futuredate() { TODAY=$(date +%s) COMPARE=$(date -d "$(date -d "$1")" +%s) test $(($COMPARE-TODAY)) -le 0 && return 1 || return 0 } #This gives a nice and structured output of coming reminders remind -s$MONTHSTOCHECKAHEAD -b1 $REMINDERSFILE | while read line do #Check if the reminder has a duration, I'm only interested in those if [ "$(echo "$line" | cut -d' ' -f 4)" != "*" ]; then #Extract the date, time and duration DATE=$(echo "$line" | cut -d' ' -f 1) TIMES=$(echo "$line" | cut -d' ' -f 6) STARTTIME=$(echo "$TIMES" | cut -d'-' -f 1) BEGDATETIME=$(date -d "$(echo $DATE $STARTTIME)") DURMINS=$(echo "$line" | cut -d' ' -f 4) #Calculate the end of the reminder ENDDATETIME=$(date -d "$(echo $BEGDATETIME +$DURMINS minutes)") #Check if the ending of this reminder is still in the future if is_futuredate "$ENDDATETIME"; then #Check if the beginning is in the past if ! is_futuredate "$BEGDATETIME"; then echo "NOW: $(echo "$line" | cut -d' ' -f 6-)" exit fi echo "$(echo "$line" | cut -d' ' -f 1,6-)" exit fi fi done
AwesomeWM Integration
To integrate it in Awesome, just put it in your scripts folder (I like ~/Scripts) and add the following to your rc.lua (Don't forget to change the location of the script):
-- {{{ Next reminder remindericon = widget({ type = "imagebox" }) remindericon.image = image(beautiful.widget_org) myreminder = widget({ type = "textbox", name = "reminder", align = "right" }) function next_reminder() local fd=io.popen("bash /home/USER/Scripts/reminderwidget", "r") --next reminder local line=fd:read() return line end myreminder.text = " " .. next_reminder() .. " " my_reminder_timer=timer({timeout=31}) my_reminder_timer:add_signal("timeout", function() myreminder.text = " " .. next_reminder() .. " " end) my_reminder_timer:start() -- }}}
Oh, and of course add myreminder to your wibox.
Fun hacks
- Give it coloured output, perhaps different colours depending on how far away the appointment is.
- Make it show a popup window with an overview when clicked.
Disclaimer
I don't think there's a lot that could go wrong here but don't blame me if you do screw up. It works fine here. You can always ask questions however, just post them below and I'll read them. (eventually)
Comments