blob: 39e63771b394941178c858a9eb9cd4a1202a302f (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
{
config,
lib,
pkgs,
...
}: let
cfg = config.soispha.services.water-reminder;
in {
options.soispha.services.water-reminder = {
enable = lib.mkEnableOption "periodic reminder for water intake";
frequency = lib.mkOption {
type = lib.types.str;
default = "*-*-* *:00/30:00"; # Every 30 minutes
description = ''
How often to remind. This value is passed to the systemd
timer configuration as the `OnCalendar` option. See
{manpage}`systemd.time(7)` for more information about the format.
'';
};
};
config = lib.mkIf cfg.enable {
home-manager.users.soispha = {
systemd.user.services.water-reminder = {
Unit = {Description = "Water reminder";};
Service = {
CPUSchedulingPolicy = "idle";
IOSchedulingClass = "idle";
ExecStart = lib.getExe (
pkgs.writeShellApplication {
name = "water-reminder";
inheritPath = false;
runtimeInputs = [pkgs.libnotify];
text =
# bash
''
notify-send 'Seek fluid intake' 'Water intake required' --wait --expire-time=0 --urgency=critical
'';
}
);
};
};
systemd.user.timers.water-reminder = {
Unit = {Description = "periodic reminder for water intake";};
Timer = {
Unit = "water-reminder.service";
OnCalendar = cfg.frequency;
};
Install = {WantedBy = ["timers.target"];};
};
};
};
}
|