sdep

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

commit e76b410b860cefe5f0a3f6c744f317899186e96b
parent b68c98a74cec75946eb29ae814da9fe6ae732cf8
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Tue, 21 Jun 2022 09:07:11 +0200

Changed folder for scripts (see README.md diff)

Diffstat:
MMakefile | 7++++---
MREADME.md | 5+++--
Mscripts/sdep-add | 6++----
Mscripts/sdep-checknow | 12+++++-------
Mscripts/sdep-clear | 6++----
Mscripts/sdep-edit | 4+---
Mscripts/sdep-list | 12+++++-------
7 files changed, 22 insertions(+), 30 deletions(-)

diff --git a/Makefile b/Makefile @@ -41,9 +41,10 @@ install: all > ${DESTDIR}${MANPREFIX}/man1/sdep.1 chmod 644 ${DESTDIR}${MANPREFIX}/man1/sdep.1 -scriptsinstall: +scripts: for s in ${SCRIPTS}; do\ - cp -f scripts/$$s ${DESTDIR}${PREFIX}/bin ; \ + sed "s|SDEPDATA|${SD}|g" < scripts/$$s > \ + ${DESTDIR}${PREFIX}/bin/$$s ; \ chmod 755 ${DESTDIR}${PREFIX}/bin/$$s ;\ done @@ -51,5 +52,5 @@ uninstall: rm -rf ${DESTDIR}${PREFIX}/bin/sdep ${DESTDIR}${MANPREFIX}/man1/sdep.1 for s in ${SCRIPTS}; do rm -rf ${DESTDIR}${PREFIX}/bin/$$s; done -.PHONY: all options clean dist install uninstall +.PHONY: all options clean dist install scripts uninstall diff --git a/README.md b/README.md @@ -88,8 +88,9 @@ between multiple devices using something like The `scripts` folder contains the few scripts that I use. They are basically just a more elaborate version of the calendar system described above, with support for recurring events (e.g. weekly, daily). You -can install them with `make scripts` and then `make scriptsinstall`, -but first make sure to adjust them to match your local configuration. +can install them with `sudo SD=/path/to/scripts/folder make scripts`, +where `SD` specifies the path where the directory where you want your sdep +files to be saved; for example it can be `/home/username/.sdep`. For example check that the folder SDEPDATA in Makefile suits you. Most of the scripts rely on the `-d` option of the GNU date utility, so you diff --git a/scripts/sdep-add b/scripts/sdep-add @@ -1,6 +1,6 @@ #!/bin/sh -# Adds a line to $sdepdata/once. It is possible to specify a date, which will be +# Adds a line to SDEPDATA/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. @@ -8,9 +8,7 @@ # Usage: sdep-add [date] # Example: sdep-add "next monday" -sdepdata="${XDG_DATA_HOME:-$HOME/.local/}/sdep" - -file="$sdepdata/once" +file="SDEPDATA/once" date="" [ -n "$1" ] && date=$(date -d "$1" +%Y-%m-%d) diff --git a/scripts/sdep-checknow b/scripts/sdep-checknow @@ -3,7 +3,7 @@ # 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 $sdepdata folder: +# The events are read from the following files in SDEPDATA 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 @@ -14,8 +14,6 @@ # might have to change if you are not on Linux (on some systems you can # accomplish the same with -j). -sdepdata="${XDG_DATA_HOME:-$HOME/.local/share}/sdep" - #notify="notify-send -t 3600000" notify=herbe title="$(date +%H:%M)" @@ -25,17 +23,17 @@ sdepnotify() { } # One-off events -sdepnotify <"$sdepdata/once" +sdepnotify <"SDEPDATA/once" # Daily events -sed "s/^/$(date +%Y-%m-%d) /" <"$sdepdata/daily" | sdepnotify +sed "s/^/$(date +%Y-%m-%d) /" <"SDEPDATA/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 <"$sdepdata/weekly" | \ +done <"SDEPDATA/weekly" | \ sdepnotify # Monthly events -sed "s/^[ ]*/$(date +%Y-%m-)/" <"$sdepdata/daily" | sdepnotify +sed "s/^[ ]*/$(date +%Y-%m-)/" <"SDEPDATA/daily" | sdepnotify diff --git a/scripts/sdep-clear b/scripts/sdep-clear @@ -1,12 +1,10 @@ #!/bin/sh -# Removes old events from specified file (default: $sdepdata/once). +# Removes old events from specified file (default: SDEPDATA/once). # Usage: sdep-clear [file] -sdepdata="${XDG_DATA_HOME:-$HOME/.local/share}/sdep" - -file="$sdepdata/${1:-once}" +file="SDEPDATA/${1:-once}" temp=$(mktemp) sdep -t <"$file" >"$temp" diff --git a/scripts/sdep-edit b/scripts/sdep-edit @@ -5,9 +5,7 @@ # Usage: sdep-edit [file] # No options = once -sdepdata="${XDG_DATA_HOME:-$HOME/.local/share}/sdep" - -file="$sdepdata/${1:-once}" +file="SDEPDATA/${1:-once}" editor=${VISUAL:-vi} $editor "$file" diff --git a/scripts/sdep-list b/scripts/sdep-list @@ -4,7 +4,7 @@ # 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 $sdepdata folder: +# The events are read from the following files in the SDEPDATA 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 @@ -15,8 +15,6 @@ # Usage: sdep-list [today|tomorrow|week|nextweek|past|future] # No options = all -sdepdata="${XDG_DATA_HOME:-$HOME/.local/share}/sdep" - from="" to="" w="%d %b %H:%M" @@ -54,13 +52,13 @@ esac tempfile=$(mktemp) -cat "$sdepdata/once" > "$tempfile" -sed "s/^/$(date +%Y-%m-%d) /" <"$sdepdata/daily" >> "$tempfile" +cat "SDEPDATA/once" > "$tempfile" +sed "s/^/$(date +%Y-%m-%d) /" <"SDEPDATA/daily" >> "$tempfile" while read line; do weekday=$(echo "$line" | sed "s/ .*$//") echo "$line" | sed "s/^[ ]*[^ ]* /$(date -d $weekday +%Y-%m-%d) /" -done <"$sdepdata/weekly" >> "$tempfile" -sed "s/^[ ]*/$(date +%Y-%m-)/" <"$sdepdata/daily" >> "$tempfile" +done <"SDEPDATA/weekly" >> "$tempfile" +sed "s/^[ ]*/$(date +%Y-%m-)/" <"SDEPDATA/daily" >> "$tempfile" sdep -w "$w" -f "$from" -t "$to" <"$tempfile"