this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

seperate out alarm script

+68
+68
hosts/profiles/desktop/alarm.sh
··· 1 + #!/usr/bin/env bash 2 + 3 + # notify a khal user via rofi about upcoming events 4 + # 5 + # dependencies: ·khal 6 + # ·rofi >= 1.7.0 (-timeout-delay 60 -timeout-action "kb-cancel") 7 + # ·column (eye candy only. can be removed without problems) 8 + # 9 + # usage: put it into a cronjob and let it run every 15 min or so 10 + # -only events with reminders will trigger an alarm (shown in khal as: ⏰) 11 + # -snoozed events will show up again on the next run 12 + # -dismissed events will not trigger an alarm again 13 + # -no alarm will be triggered if the script did never run 14 + # for the duration of an event or in TIMESPAN beforehand 15 + # 16 + # rofi: -Shift+Return toggles item selection 17 + # -if any item is selected, "cursor" position has no effect 18 + # -timeout after 60 seconds; this snoozes all events 19 + #################### 20 + 21 + 22 + # adjust cache file location to your liking 23 + cache_file="${XDG_CACHE_HOME:-$HOME/.cache}/khal-events" 24 + # events starting in the next TIMESPAN will trigger an alarm 25 + timespan='60min' 26 + #################### 27 + 28 + # this is needed for cronjobs and Xorg 29 + export DISPLAY=":0" 30 + snooze_string='💤 Snooze all.' 31 + dismiss_string='✅ Dismiss all.' 32 + # only show events with ⏰ symbol (=has alarm set) 33 + # remove arrows for all-day events to only have one notification 34 + # remove ⏰ symbol because it is obvious 35 + events="$(khal list --format \ 36 + '{calendar}: {cancelled}{start-style}{to-style}{end-style} {title}{description-separator}{description}{location}{repeat-symbol}{alarm-symbol}' \ 37 + now "${timespan}" \ 38 + | sed -ne '/⏰/ p' \ 39 + | sed -e 's/⏰//g' -e 's/\(↦\|↔\|⇥\)[^[:blank:]]*/all-day/g' \ 40 + | column -tl 3)" 41 + 42 + # get events that are new compared to cache file 43 + new_events="$(diff -NwU 0 "${cache_file}" - << EOF | sed -ne '/^\+[^+]/ p' \ 44 + | sed -ne 's/^\+\([[:print:]].*\)$/\1/p' 45 + ${events} 46 + EOF 47 + )" 48 + 49 + [ -z "${new_events}" ] && exit 0 50 + 51 + action="$(dunstify --action="default,Dismiss" --action="snooze,Snooze" "${new_events}")" 52 + 53 + # input="$(printf '%s\n%s\n%s' "${snooze_string}" \ 54 + # "${dismiss_string}" "${new_events}" \ 55 + # | rofi -timeout-delay 60 -timeout-action "kb-cancel" \ 56 + # -dmenu -i -u 2: -no-custom -multi-select -p \ 57 + # '⏰ Alarm! Select alarms to snooze. Rest will be dismissed.')" 58 + 59 + case "${action}" in 60 + "snooze") 61 + ;; 62 + "default") 63 + printf '%s' "${events}" > "${cache_file}" 64 + ;; 65 + *) 66 + printf '%s' "${events}" | grep -Fve "${input}" > "${cache_file}" 67 + ;; 68 + esac