Avoid Sleep/Suspend When no Video Signal (KVM Switch deselect)

Hi, does anyone know if it’s possible to avoid the computer going to sleep when the video signal is absent?

More specifically, I’m using a KVM Switch with a closed laptop and it goes to sleep every time the KVM Switch selects another input. Anybody knows how to prevent this?

Under the gnome settings panel select privacy → screen lock then set the timeout to never. It will then never blank the screen or lock it.

Thanks for your suggestion but it sleeps when switching KVM input, even after setting the Blank Screen Delay to Never in the Screen Lock tab from Privacy Settings.

For my computer, it will not go to sleep if I turn off my monitor (a TV via direct HDMI) or even unplug the monitor cable.

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.

interesting, is this a laptop you have?

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.

It is a desktop computer.

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.

Please have a look at logind.conf
https://www.freedesktop.org/software/systemd/man/logind.conf.html

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.