aboutsummaryrefslogtreecommitdiff
path: root/scripts-build/sdep-checknow
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano.tronto@gmail.com>2021-12-22 09:10:09 +0100
committerSebastiano Tronto <sebastiano.tronto@gmail.com>2021-12-22 09:10:09 +0100
commitd506146c55ffa28ed8f5ba2d7ebd496e60e6a8d4 (patch)
tree892cbe9b74dd914bc5b7e6148a4cfe115eaf4f76 /scripts-build/sdep-checknow
parent9902b66c098b51ac91785eb5d929a73b981ce08c (diff)
downloadsdep-d506146c55ffa28ed8f5ba2d7ebd496e60e6a8d4.tar.gz
sdep-d506146c55ffa28ed8f5ba2d7ebd496e60e6a8d4.zip
added a script to check past events and notify
Diffstat (limited to 'scripts-build/sdep-checknow')
-rw-r--r--scripts-build/sdep-checknow37
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
16notify="notify-send -t 3600000"
17title="$(date +%H:%M)"
18
19sdepnotify() {
20 sdep -w "" -s "" | while read text; do $notify "$title" "$text"; done
21}
22
23# One-off events
24sdepnotify <"/home/sebastiano/.local/share/sdep/once"
25
26# Daily events
27sed "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)
30while read line; do
31 weekday=$(echo "$line" | sed "s/ .*$//")
32 echo "$line" | sed "s/^[ ]*[^ ]* /$(date -d $weekday +%Y-%m-%d) /"
33done <"/home/sebastiano/.local/share/sdep/weekly" | \
34sdepnotify
35
36# Monthly events
37sed "s/^[ ]*/$(date +%Y-%m-)/" <"/home/sebastiano/.local/share/sdep/daily" | sdepnotify

Generated with cgit - Back to sebastiano.tronto.net