wayland: do not run xset, wayland needs another solution
This commit is contained in:
parent
fba15bd766
commit
9c2f927e72
22
screen.py
22
screen.py
@ -91,6 +91,7 @@ class KlipperScreen(Gtk.Window):
|
||||
max_retries = 4
|
||||
initialized = initializing = False
|
||||
popup_timeout = None
|
||||
wayland = False
|
||||
|
||||
def __init__(self, args, version):
|
||||
try:
|
||||
@ -117,6 +118,7 @@ class KlipperScreen(Gtk.Window):
|
||||
self.connect("configure_event", self.update_size)
|
||||
monitor = Gdk.Display.get_default().get_primary_monitor()
|
||||
if monitor is None:
|
||||
self.wayland = True
|
||||
monitor = Gdk.Display.get_default().get_monitor(0)
|
||||
if monitor is None:
|
||||
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)
|
||||
if self._config.get_main_config().get('screen_blanking') != "off":
|
||||
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):
|
||||
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'))
|
||||
|
||||
def set_screenblanking_timeout(self, time):
|
||||
os.system("xset -display :0 s blank")
|
||||
os.system("xset -display :0 s off")
|
||||
if not self.wayland:
|
||||
os.system("xset -display :0 s off")
|
||||
self.use_dpms = self._config.get_main_config().getboolean("use_dpms", fallback=True)
|
||||
|
||||
if time == "off":
|
||||
@ -596,13 +599,15 @@ class KlipperScreen(Gtk.Window):
|
||||
if self.screensaver_timeout is not None:
|
||||
GLib.source_remove(self.screensaver_timeout)
|
||||
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
|
||||
|
||||
self.blanking_time = abs(int(time))
|
||||
logging.debug(f"Changing screen blanking to: {self.blanking_time}")
|
||||
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:
|
||||
logging.info("DPMS State FAIL")
|
||||
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()
|
||||
else:
|
||||
logging.debug("Using DPMS")
|
||||
os.system("xset -display :0 s off")
|
||||
os.system(f"xset -display :0 dpms 0 {self.blanking_time} 0")
|
||||
if not self.wayland:
|
||||
os.system(f"xset -display :0 dpms 0 {self.blanking_time} 0")
|
||||
GLib.timeout_add_seconds(1, self.check_dpms_state)
|
||||
return
|
||||
# Without dpms just blank the screen
|
||||
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()
|
||||
return
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user