diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-05-08 19:19:41 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-05-08 19:19:41 +0200 |
| commit | 82bcfe3f25b1f0c08c93fd35497019b546e24ce2 (patch) | |
| tree | 055309330ff16f6d3f754b2ef6eaff92fe3925ed /scripts/sdep-checknow | |
| parent | 61d15dd4854fe4607442b87602448d6dee16b6a8 (diff) | |
| download | sdep-82bcfe3f25b1f0c08c93fd35497019b546e24ce2.tar.gz sdep-82bcfe3f25b1f0c08c93fd35497019b546e24ce2.zip | |
First commit, v0.1
Diffstat (limited to '')
| -rwxr-xr-x | scripts/sdep-checknow | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/scripts/sdep-checknow b/scripts/sdep-checknow new file mode 100755 index 0000000..0319b5f --- /dev/null +++ b/scripts/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 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: 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 <"SDEPDATA/once" | ||
| 25 | |||
| 26 | # Daily events | ||
| 27 | sed "s/^/$(date +%Y-%m-%d) /" <"SDEPDATA/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 <"SDEPDATA/weekly" | \ | ||
| 34 | sdepnotify | ||
| 35 | |||
| 36 | # Monthly events | ||
| 37 | sed "s/^[ ]*/$(date +%Y-%m-)/" <"SDEPDATA/daily" | sdepnotify | ||
