52 lines
1.7 KiB
Nix
52 lines
1.7 KiB
Nix
# Prayer time notifications, 10 minutes before each prayer and again when it is
|
|
# time, plus the waybar module that shows the same thing.
|
|
#
|
|
# Times come from github.com/WovenCoast/prayertimes-db and the lookup follows
|
|
# git.shihaam.dev/flamexode/prayertimes-sh. Every island's table is vendored, so
|
|
#
|
|
# Iteration loop: edit scripts/prayertimes.sh or config/prayertimes/islands.conf
|
|
# -> git add if new -> nixos-rebuild switch -> prayertimes.sh today, and
|
|
# pkill -SIGUSR2 waybar for the bar.
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
script = "${config.home.homeDirectory}/scripts/prayertimes.sh";
|
|
in
|
|
{
|
|
home.file."scripts/prayertimes.sh" = {
|
|
source = ../scripts/prayertimes.sh;
|
|
executable = true;
|
|
};
|
|
|
|
xdg.configFile."prayertimes/islands.conf".source =
|
|
../config/prayertimes/islands.conf;
|
|
|
|
xdg.dataFile."prayertimes".source = ../local/share/prayertimes/csv;
|
|
|
|
systemd.user.services.prayertimes = {
|
|
Unit.Description = "Announce a prayer time that has come due";
|
|
Service = {
|
|
Type = "oneshot";
|
|
# PATH here rather than a nix wrapper, so the script stays an ordinary
|
|
# executable file that can be edited and run on its own.
|
|
Environment = [
|
|
"PATH=${lib.makeBinPath (with pkgs; [ coreutils gawk gnugrep libnotify ])}"
|
|
];
|
|
ExecStart = "${script} notify";
|
|
Slice = "background.slice";
|
|
};
|
|
};
|
|
|
|
# The script decides what is due and remembers what it has announced, so a
|
|
# tick that arrives late or twice is harmless, and one missed across a suspend
|
|
# is dropped rather than announced stale.
|
|
systemd.user.timers.prayertimes = {
|
|
Unit.Description = "Prayer time notification tick";
|
|
Timer = {
|
|
OnCalendar = "*:*:00";
|
|
AccuracySec = "1s";
|
|
};
|
|
Install.WantedBy = [ "timers.target" ];
|
|
};
|
|
}
|