I run kde on my tv and want to turn the tv on and off via my cec device when kde sends the signal to turn the monitor on or off, as currently this doesn’t work on my tv.
I have found this for determining when kde tries to sleep:
from datetime import datetime
import dbus
#import gobject
from dbus.mainloop.glib import DBusGMainLoop
from gi.repository import GLib
def handle_sleep(*args):
print("%s PrepareForSleep%s" % (datetime.now().ctime(), args))
DBusGMainLoop(set_as_default=True) # integrate into gobject main loop
bus = dbus.SystemBus() # connect to system wide dbus
bus.add_signal_receiver( # define the signal to listen to
handle_sleep, # callback function
'PrepareForSleep', # signal name
'org.freedesktop.login1.Manager', # interface
'org.freedesktop.login1' # bus name
)
loop = GLib.MainLoop() #loop = gobject.MainLoop()
loop.run()
but I want to know how to intercept the monitor on/off state instead of the sleep state.
Can any one help me out with this?
edit:
The reason I want to watch the monitor state is because I don’t want my pc hooked up to the tv to actually ever go to sleep as I use it as my server. But I want to screen to be able to be turned on and off as if it had gone to sleep.