health reminder syntax fix
This commit is contained in:
@@ -12,42 +12,40 @@ lib.mkIf (host != "NxACE")
|
|||||||
};
|
};
|
||||||
|
|
||||||
systemd.user.services."health_reminder" = let
|
systemd.user.services."health_reminder" = let
|
||||||
hm = pkgs.writers.writePython3Bin "health_reminder" {
|
hm = pkgs.writers.writePython3Bin "health_reminder" {} /*python*/ ''
|
||||||
text = /*python*/ ''
|
import random
|
||||||
import random
|
import re
|
||||||
import re
|
|
||||||
|
|
||||||
class Action:
|
class Action:
|
||||||
def __init__(self, action: str, likelihood: int, options: list[str] = None):
|
def __init__(self, action: str, likelihood: int, options: list[str] = None):
|
||||||
self.action = action
|
self.action = action
|
||||||
self.likelihood = likelihood
|
self.likelihood = likelihood
|
||||||
self.options = options if options is not None else []
|
self.options = options if options is not None else []
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
try:
|
try:
|
||||||
choice = random.choice(self.options)
|
choice = random.choice(self.options)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
choice = ""
|
choice = ""
|
||||||
|
|
||||||
action = re.sub("%o", choice, self.action)
|
action = re.sub("%o", choice, self.action)
|
||||||
return action
|
return action
|
||||||
|
|
||||||
actions = [
|
actions = [
|
||||||
Action(action="look away for %o Seconds!", likelyhood=300, options=["10", "15"]),
|
Action(action="look away for %o Seconds!", likelyhood=300, options=["10", "15"]),
|
||||||
Action(action="Posture Check!", likelyhood=300),
|
Action(action="Posture Check!", likelyhood=300),
|
||||||
Action(action="Strech your upper body!", likelyhood=20),
|
Action(action="Strech your upper body!", likelyhood=20),
|
||||||
Action(action="Strech your core!", likelyhood=10),
|
Action(action="Strech your core!", likelyhood=10),
|
||||||
Action(action="Strech your legs!", likelyhood=10),
|
Action(action="Strech your legs!", likelyhood=10),
|
||||||
Action(action="Strech your arms/hands!", likelyhood=10),
|
Action(action="Strech your arms/hands!", likelyhood=10),
|
||||||
Action(action="Make Tea!", likelyhood=5),
|
Action(action="Make Tea!", likelyhood=5),
|
||||||
Action(action="说现在中文的时间!", likelyhood=2),
|
Action(action="说现在中文的时间!", likelyhood=2),
|
||||||
]
|
]
|
||||||
|
|
||||||
total_likelihood = sum(a.likelihood for a in actions)
|
total_likelihood = sum(a.likelihood for a in actions)
|
||||||
random_action = random.choices(actions, [a.likelihood for a in actions], k=1)[0]
|
random_action = random.choices(actions, [a.likelihood for a in actions], k=1)[0]
|
||||||
print(random_action)
|
print(random_action)
|
||||||
'';
|
'';
|
||||||
};
|
|
||||||
in {
|
in {
|
||||||
script = ''
|
script = ''
|
||||||
set -eu
|
set -eu
|
||||||
|
|||||||
Reference in New Issue
Block a user