2022-10-05 21:31:15 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.programs.khal;
|
|
|
|
|
|
|
|
notificationScript = pkgs.writeShellApplication {
|
|
|
|
name = "khal-notification";
|
2023-06-16 06:18:07 +02:00
|
|
|
|
|
|
|
runtimeInputs = [
|
|
|
|
pkgs.coreutils-full
|
|
|
|
pkgs.khal
|
|
|
|
pkgs.libnotify
|
2023-08-21 09:20:00 +02:00
|
|
|
pkgs.gnugrep
|
2023-06-16 06:18:07 +02:00
|
|
|
];
|
|
|
|
|
2022-10-05 21:31:15 +02:00
|
|
|
text = ''
|
|
|
|
date=$(date "+%H:%M:00")
|
2024-02-06 12:20:22 +01:00
|
|
|
events=$(khal list -d contact_birthdays -d typo3 --notstarted "$date" "$1" | (grep -v -e "Urlaub" -e "Today"; true))
|
2023-01-02 08:17:35 +01:00
|
|
|
if [ -z "$events" ]; then
|
2022-10-05 21:31:15 +02:00
|
|
|
exit 0;
|
|
|
|
fi
|
|
|
|
|
2023-06-16 06:18:07 +02:00
|
|
|
notify-send \
|
2022-10-10 21:41:14 +02:00
|
|
|
--urgency=critical \
|
|
|
|
--expire-time=90000 \
|
|
|
|
--icon="${config.gtk.iconTheme.package}/share/icons/${config.gtk.iconTheme.name}/32/apps/office-calendar.svg" \
|
|
|
|
--category="x-custom.calendar.event" \
|
|
|
|
"Upcoming Events" \
|
|
|
|
"$events"
|
2022-10-05 21:31:15 +02:00
|
|
|
exit 0
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in {
|
|
|
|
options.programs.khal = {
|
2023-06-13 10:46:58 +02:00
|
|
|
notificationFrequency = mkOption {
|
2022-10-05 21:31:15 +02:00
|
|
|
type = types.str;
|
|
|
|
default = "*:0/15";
|
|
|
|
example = "hourly";
|
|
|
|
description = ''
|
|
|
|
The notification frequency.
|
|
|
|
Check <literal>man systemd.time</literal> for more information on the syntax.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-06-13 10:46:58 +02:00
|
|
|
notificationTimeDelta = mkOption {
|
2022-10-05 21:31:15 +02:00
|
|
|
type = types.str;
|
|
|
|
default = "15m";
|
|
|
|
example = "15m";
|
|
|
|
description = "The delta to pass to khal list.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.user.services.khal_notification = {
|
|
|
|
Unit = { Description = "khal notification"; };
|
2023-06-13 10:46:58 +02:00
|
|
|
Service = { ExecStart = "${notificationScript}/bin/khal-notification \"${cfg.notificationTimeDelta}\""; };
|
2022-10-05 21:31:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
systemd.user.timers.khal_notification = {
|
|
|
|
Unit = { Description = "khal notification"; };
|
|
|
|
Timer = {
|
2023-06-13 10:46:58 +02:00
|
|
|
OnCalendar = "${cfg.notificationFrequency}";
|
2022-10-05 21:31:15 +02:00
|
|
|
Unit = "khal_notification.service";
|
|
|
|
};
|
|
|
|
Install = { WantedBy = [ "timers.target" ]; };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|