sdep

A simple "date+event" line parser
git clone https://git.tronto.net/sdep
Download | Log | Files | Refs | README | LICENSE

commit 0bcca7b6808a02af3c4758c30eec9984d44dfac7
parent c88e94d631b09d6f0839b4f96df2be974b23217e
Author: Sebastiano Tronto <sebastiano.tronto@gmail.com>
Date:   Wed,  9 Feb 2022 19:13:45 +0100

Changed notification system to herbe.

Diffstat:
Dscripts-build/sdep-add | 24------------------------
Dscripts-build/sdep-checknow | 37-------------------------------------
Dscripts-build/sdep-checkpast | 21---------------------
Dscripts-build/sdep-clear | 11-----------
Dscripts-build/sdep-edit | 11-----------
Dscripts-build/sdep-list | 65-----------------------------------------------------------------
Mscripts/sdep-checknow | 10++++++----
Mscripts/sdep-checkpast | 5+++--
Dsdep.o | 0
9 files changed, 9 insertions(+), 175 deletions(-)

diff --git a/scripts-build/sdep-add b/scripts-build/sdep-add @@ -1,24 +0,0 @@ -#!/bin/sh - -# Adds a line to /home/sebastiano/.local/share/sdep/once. It is possible to specify a date, which will be -# read by date -d and prepended to the input text. -# -d is a non-portable option of GNU date. On some other systems one can -# accomplish the same with the -j option. - -# Usage: sdep-add [date] -# Example: sdep-add "next monday" - -file="/home/sebastiano/.local/share/sdep/once" -date="" - -[ -n "$1" ] && date=$(date -d "$1" +%Y-%m-%d) - -[ -n "$date" ] && printf "$date " - -read text - -if [ -n "$text" ]; then - printf "${date}\t${text}\n" >> "$file" -else - echo "Event not saved" -fi diff --git a/scripts-build/sdep-checknow b/scripts-build/sdep-checknow @@ -1,37 +0,0 @@ -#!/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 diff --git a/scripts-build/sdep-checkpast b/scripts-build/sdep-checkpast @@ -1,21 +0,0 @@ -#!/bin/sh - -# Run this at boot to receive a notification about past events that you might -# have missed -# -# 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. - -notify="notify-send -t 3600000" - -sdep-list past | \ -while read text; do - date=$(echo "$text" | sed 's/\t.*//') - event=$(echo "$text" | sed 's/.*\t//') - $notify "$date" "$event" -done diff --git a/scripts-build/sdep-clear b/scripts-build/sdep-clear @@ -1,11 +0,0 @@ -#!/bin/sh - -# Removes old events from specified file (default: /home/sebastiano/.local/share/sdep/once). - -# Usage: sdep-clear [file] - -file="/home/sebastiano/.local/share/sdep/${1:-once}" -temp=$(mktemp) - -sdep -t <"$file" >"$temp" -mv "$temp" "$file" diff --git a/scripts-build/sdep-edit b/scripts-build/sdep-edit @@ -1,11 +0,0 @@ -#!/bin/sh - -# Open specified file in sdep folder in editor. - -# Usage: sdep-edit [file] -# No options = once - -file="/home/sebastiano/.local/share/sdep/${1:-once}" -editor=${VISUAL:-vi} - -$editor "$file" diff --git a/scripts-build/sdep-list b/scripts-build/sdep-list @@ -1,65 +0,0 @@ -#!/bin/sh - -# Lists events happening in a specific time range. -# Recurring events are listed at most once, and only if their first occurrence -# is in the range. -# -# The events are read from the following files in the /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 - -# This script uses relies on the non-portable -d option of GNU date. - -# Usage: sdep-list [today|tomorrow|week|nextweek|past|future] -# No options = all - -from="" -to="" -w="%d %b %H:%M" - -case $1 in - today) - from="$(date +%Y-%m-%d) 0:00" - to="$(date +%Y-%m-%d) 23:59" - w="%H:%M" - ;; - tomorrow) - from="$(date -d tomorrow +%Y-%m-%d) 0:00" - to="$(date -d tomorrow +%Y-%m-%d) 23:59" - w="%H:%M" - ;; - week) - from="$(date -d 'last monday' +%Y-%m-%d) 0:00" - to="$(date -d sunday +%Y-%m-%d) 23:59" - w="%a %H:%M" - ;; - nextweek) - from="$(date -d 'next monday' +%Y-%m-%d) 0:00" - to="$(date -d 'next monday + 6 days' +%Y-%m-%d) 23:59" - w="%a %H:%M" - ;; - past) - to="$(date +'%Y-%m-%d %H:%M')" - ;; - future) - from="$(date +'%Y-%m-%d %H:%M')" - ;; - *) - ;; -esac - -tempfile=$(mktemp) - -cat "/home/sebastiano/.local/share/sdep/once" > "$tempfile" -sed "s/^/$(date +%Y-%m-%d) /" <"/home/sebastiano/.local/share/sdep/daily" | >> "$tempfile" -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" >> "$tempfile" -sed "s/^[ ]*/$(date +%Y-%m-)/" <"/home/sebastiano/.local/share/sdep/daily" >> "$tempfile" - -sdep -w "$w" -f "$from" -t "$to" <"$tempfile" - -rm "$tempfile" diff --git a/scripts/sdep-checknow b/scripts/sdep-checknow @@ -9,11 +9,13 @@ # 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). +# Requires: a command to send notifications such as herbe or 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" +#notify="notify-send -t 3600000" +notify=herbe title="$(date +%H:%M)" sdepnotify() { diff --git a/scripts/sdep-checkpast b/scripts/sdep-checkpast @@ -9,9 +9,10 @@ # weekly: only specify Weekday + time # monthly: only specify day of the month + time -# Requires: notify-send. +# Requires: a command to send notifications such as herbe or notify-send. -notify="notify-send -t 3600000" +#notify="notify-send -t 3600000" +notify=herbe sdep-list past | \ while read text; do diff --git a/sdep.o b/sdep.o Binary files differ.