aboutsummaryrefslogtreecommitdiff
path: root/modules/calendar.home/orgmode-notifier.module.nix
blob: 1d6fd9063c9edfff756cbf1b473f4009318aca6b (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
34
35
36
{ 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 = [
        # NOTE: Bug in orgmode-notifier (pkgs.neovim doesnt build correctly)
        "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;
  };
}