{ config, pkgs, ... }: { systemd.timers."health_reminder" = { enable = true; wantedBy = [ "timers.target" ]; timerConfig = { OnBootSec = "5m"; OnUnitActiveSec = "5m"; Unit = "health_reminder.service"; }; }; systemd.services."health_reminder" = let hm = pkgs.writeScriptBin "health_reminder" '' #!${pkgs.python3}/bin/python3 import random class Action: def __init__(self, actionA: str, actionB: str, likelihood: int, options: str): self.actionA = actionA self.actionB = actionB self.likelihood = likelihood self.options = options def __str__(self): if self.options: return f"{self.actionA}{random.choice(self.options)}{self.actionB}" else: return self.actionA actions = [ Action("look away for 20 Seconds!", "", 300, ""), Action("Shrimp 3000!", "", 90, ""), Action("Do ", " Biceps curls with each Arm! ", 5, ["50", "10", "20"]), Action("Do ", " Shourlder thingees", 5, ["30", "50", "20"]), Action("Plank for ", " senonds!", 5, ["60", "60", "70"]), Action("Strech your upper body!", "", 10, ""), Action("Strech your core!", "", 5, ""), Action("Strech your legs!", "", 5, ""), Action("Make Tea!", "", 5, ""), ] total_likelihood = sum(a.likelihood for a in actions) random_action = random.choices(actions, [a.likelihood for a in actions], k=1)[0] print(random_action) ''; in { script = '' set -eu export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$UID/bus" ${pkgs.libnotify}/bin/notify-send "$(${hm}/bin/health_reminder)" ''; serviceConfig = { Type = "oneshot"; User = "nx2"; }; }; }