There is the DBus interface org.freedesktop.PowerManagement.Inhibit which could be used for this.
org.freedesktop.PowerManagement.Inhibit