working calendar alarms
This commit is contained in:
parent
30d6281a8f
commit
00c9c074c1
|
@ -35,7 +35,7 @@
|
|||
origin = top-right
|
||||
|
||||
# Offset from the origin
|
||||
offset = 22x28
|
||||
offset = 18x36
|
||||
|
||||
# Scale factor. It is auto-detected if value is 0.
|
||||
scale = 0
|
||||
|
@ -182,7 +182,7 @@
|
|||
hide_duplicate_count = true
|
||||
|
||||
# Display indicators for URLs (U) and actions (A).
|
||||
show_indicators = yes
|
||||
show_indicators = no
|
||||
|
||||
### Icons ###
|
||||
|
||||
|
|
|
@ -5,53 +5,13 @@
|
|||
serviceConfig.Type = "simple";
|
||||
path = [
|
||||
pkgs.libnotify
|
||||
pkgs.dunstify
|
||||
pkgs.dunst
|
||||
pkgs.khal
|
||||
pkgs.unixtools.column
|
||||
pkgs.diffutils
|
||||
];
|
||||
startAt = "*08:00:00";
|
||||
script = ''
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cache_file="${XDG_CACHE_HOME:-$HOME/.cache}/khal-events"
|
||||
# events starting in the next TIMESPAN will trigger an alarm
|
||||
timespan='60min'
|
||||
|
||||
# this is needed for cronjobs and Xorg
|
||||
export DISPLAY=":0"
|
||||
snooze_string='💤 Snooze all.'
|
||||
dismiss_string='✅ Dismiss all.'
|
||||
# only show events with ⏰ symbol (=has alarm set)
|
||||
# remove arrows for all-day events to only have one notification
|
||||
# remove ⏰ symbol because it is obvious
|
||||
events="$(khal list --format \
|
||||
'{cancelled}{start-style}{to-style}{end-style} {title}{description-separator}{description}{location}{repeat-symbol}{alarm-symbol}' \
|
||||
now "${timespan}" \
|
||||
| sed -ne '/⏰/ p' \
|
||||
| sed -e 's/⏰//g' -e 's/\(↦\|↔\|⇥\)[^[:blank:]]*/all-day/g' \
|
||||
| column -tl 3)"
|
||||
|
||||
# get events that are new compared to cache file
|
||||
new_events="$(diff -NwU 0 "${cache_file}" - << EOF | sed -ne '/^\+[^+]/ p' \
|
||||
| sed -ne 's/^\+\([[:print:]].*\)$/\1/p'
|
||||
${events}
|
||||
EOF
|
||||
)"
|
||||
|
||||
[ -z "${new_events}" ] && exit 0
|
||||
|
||||
action="$(dunstify --action="default,Dismiss" --action="snooze,Snooze" "${new_events}")"
|
||||
|
||||
case "${action}" in
|
||||
"snooze")
|
||||
;;
|
||||
"default")
|
||||
printf '%s' "${events}" > "${cache_file}"
|
||||
;;
|
||||
*)
|
||||
printf '%s' "${events}" | grep -Fve "${input}" > "${cache_file}"
|
||||
;;
|
||||
esac
|
||||
'';
|
||||
script = builtins.readFile ./alarm.sh;
|
||||
serviceConfig = {
|
||||
User = "anish";
|
||||
Environment = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus";
|
||||
|
|
Loading…
Reference in a new issue