Command to manually block sleep for KDE Connect

What you are looking for is a feature called “Inhibit”. Unfortunately it isn’t just “a command to run” - the way power management inhibition works in the FreeDesktop.org spec is that you need a process that sets the Inhibition and as long as that process runs, the power management feature is inhibited. As soon as the process ends - the inhibition ends.

If you try to run a command to set inhibition and exit - for example: qdbus org.freedesktop.PowerManagement.Inhibit /org/freedesktop/PowerManagement/Inhibit Inhibit "guard" "saving Jellyfin" then that will set the inhibition but as soon as the qdbus command ends - the inhibition will be lifted.

The common way of setting and keeping inhibition is to run the command that you want to “not be power managed” through systemd-inhibit, for example:

systemd-inhibit --what=sleep --who=guard '--why=Unsleeping for 5m' sleep 300

What this does is to tell systemd-inhibit to run the command sleep with the argument 300 and as long as it continues to run, to prevent the idle sleep power management action from triggering because an application that identifies as “guard” wants to “Unsleep for 5m”.

If you want an “on/off” switch that you can toggle on or off, you probably want to write some script or something like that that calls systemd-inhibit and knows how to terminate it. Maybe you can take inspiration from this post.