Actual solution:
Now this can be easily achieved by simple python script and as a result, Plasma will correctly recognise inhibition in it's default "Battery and Brightness" widget:

#!/usr/bin/env python3 import dbus, subprocess, sys session_bus = dbus.SessionBus() obj = session_bus.get_object('org.freedesktop.PowerManagement.Inhibit', '/org/freedesktop/PowerManagement/Inhibit') iface = dbus.Interface(obj, dbus_interface='org.freedesktop.PowerManagement.Inhibit') data = iface.Inhibit(str(sys.argv[1]), '\nfor reason: playing music') # Output report print(f'''\n---------- {sys.argv[0]} script inhibiting program: "{sys.argv[1]}" with cookie: {data} To release inhibit manually run:\n " qdbus org.freedesktop.PowerManagement.Inhibit /org/freedesktop/PowerManagement/Inhibit org.freedesktop.PowerManagement.Inhibit.UnInhibit {data} " ----------\n''') process =[1:], stderr=subprocess.STDOUT) sys.exit(process.returncode)

As a bonus, it will work with any other program, too. To use it, call script with program as arguments. For example, in desktop file:

Exec=/pathToScript/ /path_to_executable/Strawberry-0.9.3-Qt5-x86_64.AppImage %U

It will disable inhibition right after you exit Strawberry.

Well, it's not PyQt as an effort to be more portable, but from the top of my head, it can be easily achieved with QDBusConnection and QDBusInterface classes.