You have 2 different things going on.
Laptop with lid closed and kvm switch.
Try it with the lid open on the laptop and see if the kvm still puts it to sleep.
I suspect it is the combination of the 2 that is causing your problem. The kvm is likely also switching the keyboard and mouse for you so your issue is more than just the monitor.
Many laptops will go to sleep when the lid is closed even with an external monitor attached. Yours apparently does not, but removing the external connections with the kvm is likely allowing it to sleep normally.
My desktop never goes to sleep with the monitor turned off or disconnected when I set the delay to never.
Right, KVM switch moves the keyboard and mouse away. I’ll give it a try with the lid open just to know a bit more about the behavior. Really, the laptop is in a stand that keeps it closed so even if this worked I don’t think that would be a working solution for me.
Thanks for your confirmation, this is a behavior that happens in a laptop. What I expect is that in docked mode (power cable connected, lid closed) it continues to operate and not go to sleep, even if the KVM Switch is not selecting that input. I know this would work with a desktop computer and I don’t know how to make it so for a laptop.
Confirming that I did the test and with the lid open it doesn’t suspend when switching away through the KVM.
PowerKeyIgnoreInhibited=, SuspendKeyIgnoreInhibited=, HibernateKeyIgnoreInhibited=, LidSwitchIgnoreInhibited=, RebootKeyIgnoreInhibited=
Controls whether actions that systemd-logind takes when the power, reboot and sleep keys and the lid switch are triggered are subject to high-level inhibitor locks ("shutdown", "reboot", "sleep", "idle"). Low level inhibitor locks ("handle-power-key", "handle-suspend-key", "handle-hibernate-key", "handle-lid-switch", "handle-reboot-key"), are always honored, irrespective of this setting.
These settings take boolean arguments. If "no", the inhibitor locks taken by applications are respected. If "yes", "shutdown", "reboot" "sleep", and "idle" inhibitor locks are ignored. PowerKeyIgnoreInhibited=, SuspendKeyIgnoreInhibited=, HibernateKeyIgnoreInhibited= and RebootKeyIgnoreInhibited= default to "no". LidSwitchIgnoreInhibited= defaults to "yes". This means that when systemd-logind is handling events by itself (no low level inhibitor locks are taken by another application), the lid switch does not respect suspend blockers by default, but the power and sleep keys do.