I run Debian 12 with KDE on my laptop. It is set up, that it locks the screen after 10 mins of inactivity. And that is typically want I want. But some times I use it with an external screen like a TV over HDMI to watch some videos, and forget to overwrite the setting to not lock the screen.

Is there some way to not lock the screen when connected to an external screen (and preferably to AC) but resume the previous behavior if no HDMI connection is made?