From 00c9c074c1df86677e8c5c392ca76bcbddddd567 Mon Sep 17 00:00:00 2001 From: Anish Lakhwara Date: Sun, 18 Dec 2022 01:02:14 +1000 Subject: [PATCH] working calendar alarms --- home/profiles/desktop/dunstrc | 4 +-- hosts/profiles/desktop/cal-alarms.nix | 48 +++------------------------ 2 files changed, 6 insertions(+), 46 deletions(-) diff --git a/home/profiles/desktop/dunstrc b/home/profiles/desktop/dunstrc index 91d8fe16..3926caa3 100644 --- a/home/profiles/desktop/dunstrc +++ b/home/profiles/desktop/dunstrc @@ -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 ### diff --git a/hosts/profiles/desktop/cal-alarms.nix b/hosts/profiles/desktop/cal-alarms.nix index a8bc63ce..0de6ba60 100644 --- a/hosts/profiles/desktop/cal-alarms.nix +++ b/hosts/profiles/desktop/cal-alarms.nix @@ -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";