-
Notifications
You must be signed in to change notification settings - Fork 0
/
b-calendar
executable file
·51 lines (45 loc) · 1.32 KB
/
b-calendar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
calcurse_filter() {
local start end_format end
start="$(date "$1")"
end_format="${2:-+%m/%d/%Y}"
shift
shift
end="$(date "$end_format" "$@")"
calcursed -G --filter-type=apt --filter-start-from="$start" --filter-end-to="$end"
}
case "$BLOCK_BUTTON" in
1)
# send a notification with todays appointments
notify "$(calcurse_filter +'%m/%d/%Y' +'%m/%d/%Y' -d '+1 day' | tr '|' '\n')"
;;
3)
# open calcurse in my terminal
# https://sean.fish/d/cross-platform/launch?dark
launch calcursed
;;
esac
calcurse_status() {
# Find things on my calendar that are starting after now, today
# and meetings that are on my calendar, at any time today
today_coming_up="$(calcurse_filter +'%m/%d/%Y %H:%M' | wc -l)"
today_or_tomorrow="$(calcurse_filter +'%m/%d/%Y' +'%m/%d/%Y' -d '+1 day' | wc -l)"
# if all are upcoming (later in the day), just print one
if ((today_or_tomorrow == today_coming_up)); then
printf '%s\n' "$today_coming_up"
else
# print items upcoming / total items today
printf '%s/%s\n' "$today_coming_up" "$today_or_tomorrow"
fi
}
if [[ -z "$CALCURSE_DIR" ]]; then
# shellcheck disable=SC2016
notify 'No $CALCURSE_DIR set'
exit 1
fi
SYNC_CONFLICTS="$(find-sync-conflicts "$CALCURSE_DIR" | wc -l)"
if [ "$SYNC_CONFLICTS" -gt 0 ]; then
printf "%s \n" "$(calcurse_status)"
else
calcurse_status
fi