diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2022-02-09 19:13:45 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2022-02-09 19:13:45 +0100 |
| commit | 0bcca7b6808a02af3c4758c30eec9984d44dfac7 (patch) | |
| tree | 34d1e08904229c797e9aa07e656bbe2eb30d7f40 /scripts | |
| parent | c88e94d631b09d6f0839b4f96df2be974b23217e (diff) | |
| download | sdep-0bcca7b6808a02af3c4758c30eec9984d44dfac7.tar.gz sdep-0bcca7b6808a02af3c4758c30eec9984d44dfac7.zip | |
Changed notification system to herbe.
Diffstat (limited to '')
| -rw-r--r-- | scripts-build/sdep-add | 24 | ||||
| -rw-r--r-- | scripts-build/sdep-checknow | 37 | ||||
| -rw-r--r-- | scripts-build/sdep-checkpast | 21 | ||||
| -rw-r--r-- | scripts-build/sdep-clear | 11 | ||||
| -rw-r--r-- | scripts-build/sdep-edit | 11 | ||||
| -rw-r--r-- | scripts-build/sdep-list | 65 | ||||
| -rwxr-xr-x | scripts/sdep-checknow | 10 | ||||
| -rwxr-xr-x | scripts/sdep-checkpast | 5 |
8 files changed, 9 insertions, 175 deletions
diff --git a/scripts-build/sdep-add b/scripts-build/sdep-add deleted file mode 100644 index 7c25cdb..0000000 --- a/scripts-build/sdep-add +++ /dev/null | |||
| @@ -1,24 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Adds a line to /home/sebastiano/.local/share/sdep/once. It is possible to specify a date, which will be | ||
| 4 | # read by date -d and prepended to the input text. | ||
| 5 | # -d is a non-portable option of GNU date. On some other systems one can | ||
| 6 | # accomplish the same with the -j option. | ||
| 7 | |||
| 8 | # Usage: sdep-add [date] | ||
| 9 | # Example: sdep-add "next monday" | ||
| 10 | |||
| 11 | file="/home/sebastiano/.local/share/sdep/once" | ||
| 12 | date="" | ||
| 13 | |||
| 14 | [ -n "$1" ] && date=$(date -d "$1" +%Y-%m-%d) | ||
| 15 | |||
| 16 | [ -n "$date" ] && printf "$date " | ||
| 17 | |||
| 18 | read text | ||
| 19 | |||
| 20 | if [ -n "$text" ]; then | ||
| 21 | printf "${date}\t${text}\n" >> "$file" | ||
| 22 | else | ||
| 23 | echo "Event not saved" | ||
| 24 | fi | ||
diff --git a/scripts-build/sdep-checknow b/scripts-build/sdep-checknow deleted file mode 100644 index acd619d..0000000 --- a/scripts-build/sdep-checknow +++ /dev/null | |||
| @@ -1,37 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Run this every minute (for example using cron) to receive a notification | ||
| 4 | # when an event happens. | ||
| 5 | # | ||
| 6 | # The events are read from the following files in /home/sebastiano/.local/share/sdep folder: | ||
| 7 | # once: events that only happen once; full date needs to be specified | ||
| 8 | # daily: events that happen every day; only specify the time in HH:MM format | ||
| 9 | # weekly: only specify Weekday + time | ||
| 10 | # monthly: only specify day of the month + time | ||
| 11 | |||
| 12 | # Requires: notify-send; the weekly part uses the non-portable -d option of | ||
| 13 | # GNU date, which you might have to change if you are not on Linux (on some | ||
| 14 | # systems you can accomplish the same with -j). | ||
| 15 | |||
| 16 | notify="notify-send -t 3600000" | ||
| 17 | title="$(date +%H:%M)" | ||
| 18 | |||
| 19 | sdepnotify() { | ||
| 20 | sdep -w "" -s "" | while read text; do $notify "$title" "$text"; done | ||
| 21 | } | ||
| 22 | |||
| 23 | # One-off events | ||
| 24 | sdepnotify <"/home/sebastiano/.local/share/sdep/once" | ||
| 25 | |||
| 26 | # Daily events | ||
| 27 | sed "s/^/$(date +%Y-%m-%d) /" <"/home/sebastiano/.local/share/sdep/daily" | sdepnotify | ||
| 28 | |||
| 29 | # Weekly events - needs GNU date (try -j intead of -d on BSD) | ||
| 30 | while read line; do | ||
| 31 | weekday=$(echo "$line" | sed "s/ .*$//") | ||
| 32 | echo "$line" | sed "s/^[ ]*[^ ]* /$(date -d $weekday +%Y-%m-%d) /" | ||
| 33 | done <"/home/sebastiano/.local/share/sdep/weekly" | \ | ||
| 34 | sdepnotify | ||
| 35 | |||
| 36 | # Monthly events | ||
| 37 | sed "s/^[ ]*/$(date +%Y-%m-)/" <"/home/sebastiano/.local/share/sdep/daily" | sdepnotify | ||
diff --git a/scripts-build/sdep-checkpast b/scripts-build/sdep-checkpast deleted file mode 100644 index 66d6eec..0000000 --- a/scripts-build/sdep-checkpast +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Run this at boot to receive a notification about past events that you might | ||
| 4 | # have missed | ||
| 5 | # | ||
| 6 | # The events are read from the following files in /home/sebastiano/.local/share/sdep folder: | ||
| 7 | # once: events that only happen once; full date needs to be specified | ||
| 8 | # daily: events that happen every day; only specify the time in HH:MM format | ||
| 9 | # weekly: only specify Weekday + time | ||
| 10 | # monthly: only specify day of the month + time | ||
| 11 | |||
| 12 | # Requires: notify-send. | ||
| 13 | |||
| 14 | notify="notify-send -t 3600000" | ||
| 15 | |||
| 16 | sdep-list past | \ | ||
| 17 | while read text; do | ||
| 18 | date=$(echo "$text" | sed 's/\t.*//') | ||
| 19 | event=$(echo "$text" | sed 's/.*\t//') | ||
| 20 | $notify "$date" "$event" | ||
| 21 | done | ||
diff --git a/scripts-build/sdep-clear b/scripts-build/sdep-clear deleted file mode 100644 index e30fd4d..0000000 --- a/scripts-build/sdep-clear +++ /dev/null | |||
| @@ -1,11 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Removes old events from specified file (default: /home/sebastiano/.local/share/sdep/once). | ||
| 4 | |||
| 5 | # Usage: sdep-clear [file] | ||
| 6 | |||
| 7 | file="/home/sebastiano/.local/share/sdep/${1:-once}" | ||
| 8 | temp=$(mktemp) | ||
| 9 | |||
| 10 | sdep -t <"$file" >"$temp" | ||
| 11 | mv "$temp" "$file" | ||
diff --git a/scripts-build/sdep-edit b/scripts-build/sdep-edit deleted file mode 100644 index ce45cf6..0000000 --- a/scripts-build/sdep-edit +++ /dev/null | |||
| @@ -1,11 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Open specified file in sdep folder in editor. | ||
| 4 | |||
| 5 | # Usage: sdep-edit [file] | ||
| 6 | # No options = once | ||
| 7 | |||
| 8 | file="/home/sebastiano/.local/share/sdep/${1:-once}" | ||
| 9 | editor=${VISUAL:-vi} | ||
| 10 | |||
| 11 | $editor "$file" | ||
diff --git a/scripts-build/sdep-list b/scripts-build/sdep-list deleted file mode 100644 index 9292d58..0000000 --- a/scripts-build/sdep-list +++ /dev/null | |||
| @@ -1,65 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Lists events happening in a specific time range. | ||
| 4 | # Recurring events are listed at most once, and only if their first occurrence | ||
| 5 | # is in the range. | ||
| 6 | # | ||
| 7 | # The events are read from the following files in the /home/sebastiano/.local/share/sdep folder: | ||
| 8 | # once: events that only happen once; full date needs to be specified | ||
| 9 | # daily: events that happen every day; only specify the time in HH:MM format | ||
| 10 | # weekly: only specify Weekday + time | ||
| 11 | # monthly: only specify day of the month + time | ||
| 12 | |||
| 13 | # This script uses relies on the non-portable -d option of GNU date. | ||
| 14 | |||
| 15 | # Usage: sdep-list [today|tomorrow|week|nextweek|past|future] | ||
| 16 | # No options = all | ||
| 17 | |||
| 18 | from="" | ||
| 19 | to="" | ||
| 20 | w="%d %b %H:%M" | ||
| 21 | |||
| 22 | case $1 in | ||
| 23 | today) | ||
| 24 | from="$(date +%Y-%m-%d) 0:00" | ||
| 25 | to="$(date +%Y-%m-%d) 23:59" | ||
| 26 | w="%H:%M" | ||
| 27 | ;; | ||
| 28 | tomorrow) | ||
| 29 | from="$(date -d tomorrow +%Y-%m-%d) 0:00" | ||
| 30 | to="$(date -d tomorrow +%Y-%m-%d) 23:59" | ||
| 31 | w="%H:%M" | ||
| 32 | ;; | ||
| 33 | week) | ||
| 34 | from="$(date -d 'last monday' +%Y-%m-%d) 0:00" | ||
| 35 | to="$(date -d sunday +%Y-%m-%d) 23:59" | ||
| 36 | w="%a %H:%M" | ||
| 37 | ;; | ||
| 38 | nextweek) | ||
| 39 | from="$(date -d 'next monday' +%Y-%m-%d) 0:00" | ||
| 40 | to="$(date -d 'next monday + 6 days' +%Y-%m-%d) 23:59" | ||
| 41 | w="%a %H:%M" | ||
| 42 | ;; | ||
| 43 | past) | ||
| 44 | to="$(date +'%Y-%m-%d %H:%M')" | ||
| 45 | ;; | ||
| 46 | future) | ||
| 47 | from="$(date +'%Y-%m-%d %H:%M')" | ||
| 48 | ;; | ||
| 49 | *) | ||
| 50 | ;; | ||
| 51 | esac | ||
| 52 | |||
| 53 | tempfile=$(mktemp) | ||
| 54 | |||
| 55 | cat "/home/sebastiano/.local/share/sdep/once" > "$tempfile" | ||
| 56 | sed "s/^/$(date +%Y-%m-%d) /" <"/home/sebastiano/.local/share/sdep/daily" | >> "$tempfile" | ||
| 57 | while read line; do | ||
| 58 | weekday=$(echo "$line" | sed "s/ .*$//") | ||
| 59 | echo "$line" | sed "s/^[ ]*[^ ]* /$(date -d $weekday +%Y-%m-%d) /" | ||
| 60 | done <"/home/sebastiano/.local/share/sdep/weekly" >> "$tempfile" | ||
| 61 | sed "s/^[ ]*/$(date +%Y-%m-)/" <"/home/sebastiano/.local/share/sdep/daily" >> "$tempfile" | ||
| 62 | |||
| 63 | sdep -w "$w" -f "$from" -t "$to" <"$tempfile" | ||
| 64 | |||
| 65 | rm "$tempfile" | ||
diff --git a/scripts/sdep-checknow b/scripts/sdep-checknow index 0319b5f..2cb8f68 100755 --- a/scripts/sdep-checknow +++ b/scripts/sdep-checknow | |||
| @@ -9,11 +9,13 @@ | |||
| 9 | # weekly: only specify Weekday + time | 9 | # weekly: only specify Weekday + time |
| 10 | # monthly: only specify day of the month + time | 10 | # monthly: only specify day of the month + time |
| 11 | 11 | ||
| 12 | # Requires: notify-send; the weekly part uses the non-portable -d option of | 12 | # Requires: a command to send notifications such as herbe or notify-send. |
| 13 | # GNU date, which you might have to change if you are not on Linux (on some | 13 | # The weekly part uses the non-portable -d option of GNU date, which you |
| 14 | # systems you can accomplish the same with -j). | 14 | # might have to change if you are not on Linux (on some systems you can |
| 15 | # accomplish the same with -j). | ||
| 15 | 16 | ||
| 16 | notify="notify-send -t 3600000" | 17 | #notify="notify-send -t 3600000" |
| 18 | notify=herbe | ||
| 17 | title="$(date +%H:%M)" | 19 | title="$(date +%H:%M)" |
| 18 | 20 | ||
| 19 | sdepnotify() { | 21 | sdepnotify() { |
diff --git a/scripts/sdep-checkpast b/scripts/sdep-checkpast index fa8164d..35a561c 100755 --- a/scripts/sdep-checkpast +++ b/scripts/sdep-checkpast | |||
| @@ -9,9 +9,10 @@ | |||
| 9 | # weekly: only specify Weekday + time | 9 | # weekly: only specify Weekday + time |
| 10 | # monthly: only specify day of the month + time | 10 | # monthly: only specify day of the month + time |
| 11 | 11 | ||
| 12 | # Requires: notify-send. | 12 | # Requires: a command to send notifications such as herbe or notify-send. |
| 13 | 13 | ||
| 14 | notify="notify-send -t 3600000" | 14 | #notify="notify-send -t 3600000" |
| 15 | notify=herbe | ||
| 15 | 16 | ||
| 16 | sdep-list past | \ | 17 | sdep-list past | \ |
| 17 | while read text; do | 18 | while read text; do |
