aboutsummaryrefslogtreecommitdiff
path: root/scripts/p7s/systemd.py
diff options
context:
space:
mode:
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)