sdep

A simple "date+event" line parser
git clone https://git.tronto.net/sdep
Download | Log | Files | Refs | README | LICENSE

sdep-checknow (1261B)


      1 #!/bin/sh
      2 
      3 # Run this every minute (for example using cron) to receive a notification
      4 # when an event happens.
      5 #
      6 # The events are read from the following files in SDEPDATA folder:
      7 #	once: events that only happen once; full date needs to be specified
      8 #	daily: events that happen every day; only specify the time in HH:MM format
      9 #	weekly: only specify Weekday + time
     10 #	monthly: only specify day of the month + time
     11 
     12 # Requires: a command to send notifications such as herbe or notify-send.
     13 # The weekly part uses the non-portable -d option of GNU date, which you
     14 # might have to change if you are not on Linux (on some systems you can
     15 # accomplish the same with -j).
     16 
     17 #notify="notify-send -t 3600000"
     18 notify=herbe
     19 title="$(date +%H:%M)"
     20 
     21 sdepnotify() {
     22 	sdep -w "" -s "" | while read text; do $notify "$title" "$text"; done
     23 }
     24 
     25 # One-off events
     26 sdepnotify <"SDEPDATA/once"
     27 
     28 # Daily events
     29 sed "s/^/$(date +%Y-%m-%d) /" <"SDEPDATA/daily" | sdepnotify 
     30 
     31 # Weekly events - needs GNU date (try -j intead of -d on BSD)
     32 while read line; do
     33 	weekday=$(echo "$line" | sed "s/ .*$//")
     34 	echo "$line" | sed "s/^[ ]*[^ ]* /$(date -d $weekday +%Y-%m-%d) /"
     35 done <"SDEPDATA/weekly" | \
     36 sdepnotify
     37 
     38 # Monthly events
     39 sed "s/^[ ]*/$(date +%Y-%m-)/" <"SDEPDATA/daily" | sdepnotify