Exemple #1
0
    def check_dpms_state(self):
        state = functions.get_DPMS_state()

        if state == functions.DPMS_State.Fail:
            logging.info(
                "DPMS State FAIL -> Showing KlipperScreen, Stopping DPMS Check"
            )
            self.show()
            self.change_cursor()
            return False

        visible = self.get_property("visible")
        if state != functions.DPMS_State.On and visible:
            logging.info("DPMS State %s -> Hiding", state)
            self.hide()
            self.change_cursor("watch")
            self.touch_ready = False
        elif state == functions.DPMS_State.On and not visible:
            if self.touch_ready:
                logging.info("DPMS State On -> Showing KlipperScreen")
                self.show()
                self.change_cursor()
            else:
                logging.info("DPMS State On -> Screen touched")
                self.touch_ready = True
        else:
            self.touch_ready = False
        return True
 def check_dpms_state(self):
     state = functions.get_DPMS_state()
     if state == functions.DPMS_State.Off and "screensaver" not in self._cur_panels:
         logging.info("### Creating screensaver panel")
         self.show_panel("screensaver", "screensaver", "Screen Saver", 1, False)
     elif state == functions.DPMS_State.On and "screensaver" in self._cur_panels:
         logging.info("### Remove screensaver panel")
         self._menu_go_back()
     return True
    def check_dpms_state(self):
        state = functions.get_DPMS_state()

        if state == functions.DPMS_State.Fail:
            logging.info("DPMS State FAIL: Stopping DPMS Check")
            if self.screensaver_timeout is None:
                self.set_dpms(False)
            return False
        elif state != functions.DPMS_State.On:
            if self.screensaver is None:
                self.show_screensaver()
        return True
    def set_screenblanking_timeout(self, time):
        os.system("xset -display :0 s noblank")
        os.system("xset -display :0 s off")
        self.use_dpms = self._config.get_main_config().getboolean(
            "use_dpms", fallback=True)

        if time == "off":
            logging.debug(f"Screen blanking: {time}")
            if self.dpms_timeout is not None:
                GLib.source_remove(self.dpms_timeout)
                self.dpms_timeout = None
            if self.screensaver_timeout is not None:
                GLib.source_remove(self.screensaver_timeout)
            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 functions.get_DPMS_state() == functions.DPMS_State.Fail:
                logging.info("DPMS State FAIL")
            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 self.dpms_timeout is None:
                    self.dpms_timeout = GLib.timeout_add_seconds(
                        1, self.check_dpms_state)
                return
        # Without dpms just blank the screen
        logging.debug("Not using DPMS")
        if self.dpms_timeout is not None:
            GLib.source_remove(self.dpms_timeout)
            self.dpms_timeout = None
        os.system("xset -display :0 dpms 0 0 0")
        if self.screensaver_timeout is None:
            self.screensaver_timeout = GLib.timeout_add_seconds(
                self.blanking_time, self.show_screensaver)
        return