From d506146c55ffa28ed8f5ba2d7ebd496e60e6a8d4 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Wed, 22 Dec 2021 09:10:09 +0100 Subject: added a script to check past events and notify --- scripts-build/sdep-checknow | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 scripts-build/sdep-checknow (limited to 'scripts-build/sdep-checknow') 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 @@ +#!/bin/sh + +# Run this every minute (for example using cron) to receive a notification +# when an event happens. +# +# The events are read from the following files in /home/sebastiano/.local/share/sdep folder: +# once: events that only happen once; full date needs to be specified +# daily: events that happen every day; only specify the time in HH:MM format +# weekly: only specify Weekday + time +# monthly: only specify day of the month + time + +# Requires: notify-send; the weekly part uses the non-portable -d option of +# GNU date, which you might have to change if you are not on Linux (on some +# systems you can accomplish the same with -j). + +notify="notify-send -t 3600000" +title="$(date +%H:%M)" + +sdepnotify() { + sdep -w "" -s "" | while read text; do $notify "$title" "$text"; done +} + +# One-off events +sdepnotify <"/home/sebastiano/.local/share/sdep/once" + +# Daily events +sed "s/^/$(date +%Y-%m-%d) /" <"/home/sebastiano/.local/share/sdep/daily" | sdepnotify + +# Weekly events - needs GNU date (try -j intead of -d on BSD) +while read line; do + weekday=$(echo "$line" | sed "s/ .*$//") + echo "$line" | sed "s/^[ ]*[^ ]* /$(date -d $weekday +%Y-%m-%d) /" +done <"/home/sebastiano/.local/share/sdep/weekly" | \ +sdepnotify + +# Monthly events +sed "s/^[ ]*/$(date +%Y-%m-)/" <"/home/sebastiano/.local/share/sdep/daily" | sdepnotify -- cgit v1.3