aboutsummaryrefslogtreecommitdiff
path: root/scripts/p7s/systemd.py
diff options
context:
space:
mode:
authoralex <alex@pdp7.net>2025-09-07 15:51:09 +0000
committeralexpdp7 <alex@corcoles.net>2025-09-07 19:48:23 +0200
commitad8667c28db6ea061c3787e9a39cbb6ce41e4bdf (patch)
treef160a38aab391a688c5e5e039c91c2a510132371 /scripts/p7s/systemd.py
parent7eae7d5d055526affb0f94476a464a62d73dd265 (diff)
Add setup-imapfilter
Diffstat (limited to 'scripts/p7s/systemd.py')
-rw-r--r--scripts/p7s/systemd.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/scripts/p7s/systemd.py b/scripts/p7s/systemd.py
new file mode 100644
index 00000000..3c2270f4
--- /dev/null
+++ b/scripts/p7s/systemd.py
@@ -0,0 +1,21 @@
+import getpass
+import pathlib
+import subprocess
+
+
+def create_user_unit(name, content):
+ user_units = pathlib.Path.home() / ".config" / "systemd" / "user"
+ user_units.mkdir(exist_ok=True, parents=True)
+ (user_units / name).write_text(content)
+
+
+def reload():
+ subprocess.run(["systemctl", "--user", "daemon-reload"], check=True)
+
+
+def enable_now(unit):
+ subprocess.run(["systemctl", "--user", "enable", "--now", unit], check=True)
+
+
+def enable_linger():
+ subprocess.run(["sudo", "loginctl", "enable-linger", getpass.getuser()], check=True)