Open danielphan2003 opened 2 years ago
If you don't want to depend on forking, you can use control group to launch commands, though I think swhkd should be vendor agnostic and should not depend on any init system to launch commands on its own. Therefore, you have to wrap your own commands with a wrapper that create a control group behind the scene, so without forking other processes would still run even when you stop swhks service. I will leave this for comments, since I don't know of a better way to do this.
Note that I also haven't really figure out how to terminate shkwd via systemd. Granted, you can reload, pause loading or continue loading config file with HUP or USR signals, but systemd sending SIGTERM just won't do it. Probably because swhkd is running with pkexec.
- I totally agree that a tool like swhkd should be 100% init system independent.
- Do you think we should create a cgroup right on startup of swhks and then fork into it?
- I'm not too familiar with cgroup syscalls so if you think you can expand on this by patching it into swhks, I'd be more than happy to merge it.
I think so, though I'm also not familiar with cgroup syscalls. Let's just hope something else come up while I'm getting used to the syscalls.
I have a working example here:
[Service]
ExecStart=/path/to/swhkd-start.sh
ExecReload=/bin/kill -HUP swhkd Restart=always Type=simple
[Unit] Description=swhkd hotkey server After=graphical-session-pre.target PartOf=graphical-session.target
[Service]
ExecStart=/path/to/swhks-start.sh
KillMode=process PIDFile=/run/user/1000/swhks.pid RemainAfterExit=true Restart=always Type=forking
[Install] WantedBy=graphical-session.target
!/bin/sh
pkexec swhkd
!/bin/sh
killall swhks swhks &