From b8199c24ef6de460ccfed6085ab6c6a1c67439f6 Mon Sep 17 00:00:00 2001 From: "Lennart J. Kurzweg (Nx2)" Date: Thu, 21 Nov 2024 22:27:28 +0100 Subject: [PATCH] health reminder syntax fix --- system-modules/health_reminder.nix | 62 +++++++++++++++--------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/system-modules/health_reminder.nix b/system-modules/health_reminder.nix index 494df26..7e02ee2 100755 --- a/system-modules/health_reminder.nix +++ b/system-modules/health_reminder.nix @@ -12,42 +12,40 @@ lib.mkIf (host != "NxACE") }; systemd.user.services."health_reminder" = let - hm = pkgs.writers.writePython3Bin "health_reminder" { - text = /*python*/ '' - import random - import re + hm = pkgs.writers.writePython3Bin "health_reminder" {} /*python*/ '' + import random + import re - class Action: - def __init__(self, action: str, likelihood: int, options: list[str] = None): - self.action = action - self.likelihood = likelihood - self.options = options if options is not None else [] + class Action: + def __init__(self, action: str, likelihood: int, options: list[str] = None): + self.action = action + self.likelihood = likelihood + self.options = options if options is not None else [] - def __str__(self): - try: - choice = random.choice(self.options) - except IndexError: - choice = "" - - action = re.sub("%o", choice, self.action) - return action + def __str__(self): + try: + choice = random.choice(self.options) + except IndexError: + choice = "" + + action = re.sub("%o", choice, self.action) + return action - actions = [ - Action(action="look away for %o Seconds!", likelyhood=300, options=["10", "15"]), - Action(action="Posture Check!", likelyhood=300), - Action(action="Strech your upper body!", likelyhood=20), - Action(action="Strech your core!", likelyhood=10), - Action(action="Strech your legs!", likelyhood=10), - Action(action="Strech your arms/hands!", likelyhood=10), - Action(action="Make Tea!", likelyhood=5), - Action(action="说现在中文的时间!", likelyhood=2), - ] + actions = [ + Action(action="look away for %o Seconds!", likelyhood=300, options=["10", "15"]), + Action(action="Posture Check!", likelyhood=300), + Action(action="Strech your upper body!", likelyhood=20), + Action(action="Strech your core!", likelyhood=10), + Action(action="Strech your legs!", likelyhood=10), + Action(action="Strech your arms/hands!", likelyhood=10), + Action(action="Make Tea!", likelyhood=5), + Action(action="说现在中文的时间!", likelyhood=2), + ] - 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) - ''; - }; + 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