blob: 76e5aafa78f258c4b7d979ab11abcc4bf9f0459f (
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
58
59
60
61
62
63
64
65
66
|
# nixos-config - My current NixOS configuration
#
# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of my nixos-config.
#
# You should have received a copy of the License along with this program.
# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
{
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"];};
};
};
};
}
|