wayland: do not run xset, wayland needs another solution

This commit is contained in:
alfrix 2023-08-27 23:30:58 -03:00
parent fba15bd766
commit 9c2f927e72

View File

@ -91,6 +91,7 @@ class KlipperScreen(Gtk.Window):
max_retries = 4 max_retries = 4
initialized = initializing = False initialized = initializing = False
popup_timeout = None popup_timeout = None
wayland = False
def __init__(self, args, version): def __init__(self, args, version):
try: try:
@ -117,6 +118,7 @@ class KlipperScreen(Gtk.Window):
self.connect("configure_event", self.update_size) self.connect("configure_event", self.update_size)
monitor = Gdk.Display.get_default().get_primary_monitor() monitor = Gdk.Display.get_default().get_primary_monitor()
if monitor is None: if monitor is None:
self.wayland = True
monitor = Gdk.Display.get_default().get_monitor(0) monitor = Gdk.Display.get_default().get_monitor(0)
if monitor is None: if monitor is None:
raise RuntimeError("Couldn't get default monitor") raise RuntimeError("Couldn't get default monitor")
@ -579,7 +581,8 @@ class KlipperScreen(Gtk.Window):
# Wake the screen (it will go to standby as configured) # Wake the screen (it will go to standby as configured)
if self._config.get_main_config().get('screen_blanking') != "off": if self._config.get_main_config().get('screen_blanking') != "off":
logging.debug("Screen wake up") logging.debug("Screen wake up")
os.system("xset -display :0 dpms force on") if not self.wayland:
os.system("xset -display :0 dpms force on")
def set_dpms(self, use_dpms): def set_dpms(self, use_dpms):
self.use_dpms = use_dpms self.use_dpms = use_dpms
@ -587,8 +590,8 @@ class KlipperScreen(Gtk.Window):
self.set_screenblanking_timeout(self._config.get_main_config().get('screen_blanking')) self.set_screenblanking_timeout(self._config.get_main_config().get('screen_blanking'))
def set_screenblanking_timeout(self, time): def set_screenblanking_timeout(self, time):
os.system("xset -display :0 s blank") if not self.wayland:
os.system("xset -display :0 s off") os.system("xset -display :0 s off")
self.use_dpms = self._config.get_main_config().getboolean("use_dpms", fallback=True) self.use_dpms = self._config.get_main_config().getboolean("use_dpms", fallback=True)
if time == "off": if time == "off":
@ -596,13 +599,15 @@ class KlipperScreen(Gtk.Window):
if self.screensaver_timeout is not None: if self.screensaver_timeout is not None:
GLib.source_remove(self.screensaver_timeout) GLib.source_remove(self.screensaver_timeout)
self.screensaver_timeout = None self.screensaver_timeout = None
os.system("xset -display :0 dpms 0 0 0") if not self.wayland:
os.system("xset -display :0 dpms 0 0 0")
return return
self.blanking_time = abs(int(time)) self.blanking_time = abs(int(time))
logging.debug(f"Changing screen blanking to: {self.blanking_time}") logging.debug(f"Changing screen blanking to: {self.blanking_time}")
if self.use_dpms and functions.dpms_loaded is True: if self.use_dpms and functions.dpms_loaded is True:
os.system("xset -display :0 +dpms") if not self.wayland:
os.system("xset -display :0 +dpms")
if functions.get_DPMS_state() == functions.DPMS_State.Fail: if functions.get_DPMS_state() == functions.DPMS_State.Fail:
logging.info("DPMS State FAIL") logging.info("DPMS State FAIL")
self.show_popup_message(_("DPMS has failed to load and has been disabled")) self.show_popup_message(_("DPMS has failed to load and has been disabled"))
@ -610,13 +615,14 @@ class KlipperScreen(Gtk.Window):
self._config.save_user_config_options() self._config.save_user_config_options()
else: else:
logging.debug("Using DPMS") logging.debug("Using DPMS")
os.system("xset -display :0 s off") if not self.wayland:
os.system(f"xset -display :0 dpms 0 {self.blanking_time} 0") os.system(f"xset -display :0 dpms 0 {self.blanking_time} 0")
GLib.timeout_add_seconds(1, self.check_dpms_state) GLib.timeout_add_seconds(1, self.check_dpms_state)
return return
# Without dpms just blank the screen # Without dpms just blank the screen
logging.debug("Not using DPMS") logging.debug("Not using DPMS")
os.system("xset -display :0 dpms 0 0 0") if not self.wayland:
os.system("xset -display :0 dpms 0 0 0")
self.reset_screensaver_timeout() self.reset_screensaver_timeout()
return return