aboutsummaryrefslogtreecommitdiff
path: root/scripts-build/sdep-list
diff options
context:
space:
mode:
Diffstat (limited to 'scripts-build/sdep-list')
-rw-r--r--scripts-build/sdep-list65
1 files changed, 65 insertions, 0 deletions
diff --git a/scripts-build/sdep-list b/scripts-build/sdep-list
new file mode 100644
index 0000000..9292d58
--- /dev/null
+++ b/scripts-build/sdep-list
@@ -0,0 +1,65 @@
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
18from=""
19to=""
20w="%d %b %H:%M"
21
22case $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 ;;
51esac
52
53tempfile=$(mktemp)
54
55cat "/home/sebastiano/.local/share/sdep/once" > "$tempfile"
56sed "s/^/$(date +%Y-%m-%d) /" <"/home/sebastiano/.local/share/sdep/daily" | >> "$tempfile"
57while read line; do
58 weekday=$(echo "$line" | sed "s/ .*$//")
59 echo "$line" | sed "s/^[ ]*[^ ]* /$(date -d $weekday +%Y-%m-%d) /"
60done <"/home/sebastiano/.local/share/sdep/weekly" >> "$tempfile"
61sed "s/^[ ]*/$(date +%Y-%m-)/" <"/home/sebastiano/.local/share/sdep/daily" >> "$tempfile"
62
63sdep -w "$w" -f "$from" -t "$to" <"$tempfile"
64
65rm "$tempfile"

Generated with cgit - Back to sebastiano.tronto.net