aboutsummaryrefslogtreecommitdiff
path: root/modules/calendar.home/orgmode-notifier.module.nix
blob: b33c2feaf7fb87c6321224ab0421c968802413ba (plain) (blame)
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
{ config, pkgs, lib, ... }:
with lib;
let
  cfg = config.services.orgmode-notifier;

  service-unit = {
    Service = {
      Type = "oneshot";
      ExecStart = "${config.xdg.configHome}/nvim/orgmode_notifier.sh";
      WorkingDirectory = config.home.homeDirectory;
      Environment = "PATH=${pkgs.neovim}/bin:${pkgs.libnotify}/bin:/usr/bin:/bin";
    };
  };

  timer-unit = {
    Timer = {
      OnCalendar = cfg.pollFrequency;
      RandomizedDelaySec = 30;
    };
    Install.WantedBy = [ "timers.target" ];
  };
in {
  options.services.orgmode-notifier = {
    enable = mkEnableOption "orgmode notifier";
    pollFrequency = mkOption { type = types.str; default = "*:0/1"; };
  };

  config = mkIf cfg.enable {
    programs.lieer.enable = true;
    systemd.user.services.orgmode-notifier = service-unit;
    systemd.user.timers.orgmode-notifier = timer-unit;
  };
}