I'm currently working on setting up a VM for Windows 10 with single GPU pass-through (https://gitlab.com/risingprismtv/single-gpu-passthrough/-/wikis/home). Among the usual set of scripts needed for this to work is usually a systemd service containing the following to prevent the system from sleeping when
libvirtd is active.
[Unit]
Description=Preventing sleep while libvirt domain "%i" is running
[Service]
Type=simple
ExecStart=/usr/bin/systemd-inhibit --what=sleep --why="Libvirt domain \"%i\" is running" --who=%U --mode=block sleep infinity
My question is, what would the runit equivalent for such a service be? Does runit have its own command to inhibit actions like Sleep with?
Runit stores running services in a file in /etc/runit/runsvdir/current, so having a shell script check if that file exists (with optionally safeties for the PID and the loop itself) should suffice.
A command for inhibiting sleep is however more difficult since the recommended way would be with kernel boot parameter, and you need something at runtime, so the next way is within /etc/elogind/logind.conf, you can make copies or edit directly with awk the lines related to sleep/idle/etc.