#!/usr/bin/env python3 from pathlib import Path from subprocess import check_call run_script = Path(__file__).parent.joinpath('run').absolute() CONFIG = f""" [Unit] Description=Grasp extension server conterpart [Install] WantedBy=default.target [Service] ExecStart={run_script} Type=simple Restart=always """ SNAME = 'grasp.service' out = Path(f'~/.config/systemd/user/{SNAME}').expanduser() print(f"Writing systemd config to {out}:") with out.open('w') as fo: fo.write(CONFIG) def systemd(*args): check_call([ 'systemctl', '--user', *args, ]) systemd('daemon-reload') systemd('enable', SNAME) systemd('start' , SNAME) systemd('status', SNAME) # TODO journalctl --user -u grasp.service to debug