From 2836d2f4452b538e24ca6b85ee27df7bce0b69b2 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Wed, 9 Feb 2022 19:23:08 +0100 Subject: Simplified scripts build process (removed SDEPDATA). --- scripts/sdep-add | 6 ++++-- scripts/sdep-checknow | 12 +++++++----- scripts/sdep-checkpast | 8 +------- scripts/sdep-clear | 6 ++++-- scripts/sdep-edit | 4 +++- scripts/sdep-list | 12 +++++++----- 6 files changed, 26 insertions(+), 22 deletions(-) (limited to 'scripts') diff --git a/scripts/sdep-add b/scripts/sdep-add index bb0b2c8..c9f4344 100755 --- 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,7 +8,9 @@ # Usage: sdep-add [date] # Example: sdep-add "next monday" -file="SDEPDATA/once" +sdepdata="${XDG_DATA_HOME:-$HOME/.local}/sdep" + +file="$sdepdata/once" date="" [ -n "$1" ] && date=$(date -d "$1" +%Y-%m-%d) diff --git a/scripts/sdep-checknow b/scripts/sdep-checknow index 2cb8f68..404d461 100755 --- 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,6 +14,8 @@ # 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}/sdep" + #notify="notify-send -t 3600000" notify=herbe title="$(date +%H:%M)" @@ -23,17 +25,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-checkpast b/scripts/sdep-checkpast index 35a561c..e5686fb 100755 --- a/scripts/sdep-checkpast +++ b/scripts/sdep-checkpast @@ -1,13 +1,7 @@ #!/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 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 -# monthly: only specify day of the month + time +# have missed (based on sdep-list). # Requires: a command to send notifications such as herbe or notify-send. diff --git a/scripts/sdep-clear b/scripts/sdep-clear index 814f853..98599ef 100755 --- a/scripts/sdep-clear +++ b/scripts/sdep-clear @@ -1,10 +1,12 @@ #!/bin/sh -# Removes old events from specified file (default: SDEPDATA/once). +# Removes old events from specified file (default: $sdepdata/once). # Usage: sdep-clear [file] -file="SDEPDATA/${1:-once}" +sdepdata="${XDG_DATA_HOME:-$HOME/.local}/sdep" + +file="$sdepdata/${1:-once}" temp=$(mktemp) sdep -t <"$file" >"$temp" diff --git a/scripts/sdep-edit b/scripts/sdep-edit index d19a3f5..b561dd8 100755 --- a/scripts/sdep-edit +++ b/scripts/sdep-edit @@ -5,7 +5,9 @@ # Usage: sdep-edit [file] # No options = once -file="SDEPDATA/${1:-once}" +sdepdata="${XDG_DATA_HOME:-$HOME/.local}/sdep" + +file="$sdepdata/${1:-once}" editor=${VISUAL:-vi} $editor "$file" diff --git a/scripts/sdep-list b/scripts/sdep-list index a9e5405..c1e89f9 100755 --- 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,6 +15,8 @@ # Usage: sdep-list [today|tomorrow|week|nextweek|past|future] # No options = all +sdepdata="${XDG_DATA_HOME:-$HOME/.local}/sdep" + from="" to="" w="%d %b %H:%M" @@ -52,13 +54,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" -- cgit v1.3