diff options
Diffstat (limited to 'scripts-build/sdep-checknow')
| -rw-r--r-- | scripts-build/sdep-checknow | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/scripts-build/sdep-checknow b/scripts-build/sdep-checknow new file mode 100644 index 0000000..acd619d --- /dev/null +++ b/scripts-build/sdep-checknow | |||
| @@ -0,0 +1,37 @@ | |||
| 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 /home/sebastiano/.local/share/sdep 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: notify-send; the weekly part uses the non-portable -d option of | ||
| 13 | # GNU date, which you might have to change if you are not on Linux (on some | ||
| 14 | # systems you can accomplish the same with -j). | ||
| 15 | |||
| 16 | notify="notify-send -t 3600000" | ||
| 17 | title="$(date +%H:%M)" | ||
| 18 | |||
| 19 | sdepnotify() { | ||
| 20 | sdep -w "" -s "" | while read text; do $notify "$title" "$text"; done | ||
| 21 | } | ||
| 22 | |||
| 23 | # One-off events | ||
| 24 | sdepnotify <"/home/sebastiano/.local/share/sdep/once" | ||
| 25 | |||
| 26 | # Daily events | ||
| 27 | sed "s/^/$(date +%Y-%m-%d) /" <"/home/sebastiano/.local/share/sdep/daily" | sdepnotify | ||
| 28 | |||
| 29 | # Weekly events - needs GNU date (try -j intead of -d on BSD) | ||
| 30 | while read line; do | ||
| 31 | weekday=$(echo "$line" | sed "s/ .*$//") | ||
| 32 | echo "$line" | sed "s/^[ ]*[^ ]* /$(date -d $weekday +%Y-%m-%d) /" | ||
| 33 | done <"/home/sebastiano/.local/share/sdep/weekly" | \ | ||
| 34 | sdepnotify | ||
| 35 | |||
| 36 | # Monthly events | ||
| 37 | sed "s/^[ ]*/$(date +%Y-%m-)/" <"/home/sebastiano/.local/share/sdep/daily" | sdepnotify | ||
