commit 49f83b383d9048ce3d620a91a4005245aa1599dc
parent 7d3dc968b6183f51dc2594c80450372f0c8fb811
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Mon, 23 Dec 2024 10:22:02 +0100
Added notify-loop
Diffstat:
M | event | | | 19 | +++++++++++++++++++ |
1 file changed, 19 insertions(+), 0 deletions(-)
diff --git a/event b/event
@@ -7,6 +7,7 @@
file="$HOME/box/events" # Change to $XDG_DATA_HOME/events or whatever
editor=${EDITOR:-vi}
+notify=${NOTIFY:-"notify push"}
usage() {
echo "Usage: event [command]"
@@ -19,6 +20,8 @@ usage() {
echo " date: now, n; today, t; tomorrow, tm;"
echo " week, w; nextweek, nw;"
echo " future, f; past, p"
+ echo " notify-loop Notify of all past events, then start a loop that"
+ echo " checks for events every minute and notifies"
}
secondstoday() {
@@ -148,6 +151,22 @@ case "$1" in
list)
cat "$file" | list $2 | sort
;;
+ notify-loop)
+ clean="sed -E 's/....-..-.. .{1,2}:..[[:space:]]*//g'"
+ cat "$file" | list past | sort | \
+ sed -E 's/....-..-.. .{1,2}:..[[:space:]]*//g' | \
+ while read text; do
+ $notify "$text"
+ done &
+ while true; do
+ cat "$file" | list now | sort | \
+ sed -E 's/....-..-.. .{1,2}:..[[:space:]]*//g' | \
+ while read text; do
+ $notify "$text"
+ done &
+ sleep $((60 - $(date +%-S)))
+ done
+ ;;
*)
usage
;;