예제 #1
0
    def __init__(
        self,
        kore: base.Core,
        config,
        *,
        socket_path: str = None,
        no_spawn=False,
        state=None,
    ) -> None:
        """Manages a qtile session

        :param kore:
            The core backend to use for the session.
        :param config:
            The configuration to use for the qtile instance.
        :param socket_path:
            The file name to use as the qtile socket file.
        :param no_spawn:
            If the instance has already been started, then don't re-run the
            startup once hook.
        :param state:
            The state to restart the qtile instance with.
        """
        lifecycle.behavior = lifecycle.behavior.TERMINATE

        self.qtile = Qtile(kore, config, no_spawn=no_spawn, state=state)
        self.server = ipc.Server(
            self._prepare_socket_path(socket_path),
            self.qtile.server.call,
        )
예제 #2
0
파일: start.py 프로젝트: tusqasi/qtile
def make_qtile(options):
    kore = libqtile.backend.get_core(options.backend)

    if not path.isfile(options.configfile):
        try:
            makedirs(path.dirname(options.configfile), exist_ok=True)
            from shutil import copyfile

            default_config_path = path.join(path.dirname(__file__), "..",
                                            "resources", "default_config.py")
            copyfile(default_config_path, options.configfile)
            logger.info("Copied default_config.py to %s", options.configfile)
        except Exception as e:
            logger.exception("Failed to copy default_config.py to %s: (%s)",
                             options.configfile, e)

    config = confreader.Config(options.configfile)

    # XXX: the import is here because we need to call init_log
    # before start importing stuff
    from libqtile.core.manager import Qtile

    return Qtile(
        kore,
        config,
        no_spawn=options.no_spawn,
        state=options.state,
        socket_path=options.socket,
    )
예제 #3
0
 def run_qtile():
     try:
         kore = Core(display_name=self.display)
         init_log(self.log_level, log_path=None, log_color=False)
         Qtile(
             kore,
             config_class(),
             socket_path=self.sockfile,
             no_spawn=no_spawn,
         ).loop()
     except Exception:
         wpipe.send(traceback.format_exc())
예제 #4
0
    def create_manager(self, config_class):
        """Create a Qtile manager instance in this thread

        This should only be used when it is known that the manager will throw
        an error and the returned manager should not be started, otherwise this
        will likely block the thread.
        """
        init_log(self.log_level, log_path=None, log_color=False)
        kore = self.backend.create()
        config = config_class()
        for attr in dir(default_config):
            if not hasattr(config, attr):
                setattr(config, attr, getattr(default_config, attr))

        return Qtile(kore, config, socket_path=self.sockfile)
예제 #5
0
파일: helpers.py 프로젝트: stonewell/qtile
 def run_qtile():
     try:
         os.environ.pop("DISPLAY", None)
         os.environ.pop("WAYLAND_DISPLAY", None)
         kore = self.backend.create()
         os.environ.update(self.backend.env)
         init_log(self.log_level, log_path=None, log_color=False)
         Qtile(
             kore,
             config_class(),
             socket_path=self.sockfile,
             no_spawn=no_spawn,
         ).loop()
     except Exception:
         wpipe.send(traceback.format_exc())
예제 #6
0
 def run_qtile():
     try:
         os.environ.pop("DISPLAY", None)
         os.environ.pop("WAYLAND_DISPLAY", None)
         kore = self.backend.create()
         os.environ.update(self.backend.env)
         logger = init_log(self.log_level, log_path=None, log_color=False)
         if hasattr(self, "log_queue"):
             logger.addHandler(logging.handlers.QueueHandler(self.log_queue))
         Qtile(
             kore,
             config_class(),
             socket_path=self.sockfile,
             no_spawn=no_spawn,
             state=state,
         ).loop()
     except Exception:
         wpipe.send(traceback.format_exc())
예제 #7
0
    def __init__(self,
                 kore: base.Core,
                 config,
                 *,
                 fname: str = None,
                 no_spawn=False,
                 state=None) -> None:
        """Manages a qtile session

        :param kore:
            The core backend to use for the session.
        :param config:
            The configuration to use for the qtile instance.
        :param fname:
            The file name to use as the qtile socket file.
        :param no_spawn:
            If the instance has already been started, then don't re-run the
            startup once hook.
        :param state:
            The state to restart the qtile instance with.
        """
        eventloop = asyncio.new_event_loop()
        asyncio.set_event_loop(eventloop)

        self.qtile = Qtile(kore,
                           config,
                           eventloop,
                           no_spawn=no_spawn,
                           state=state)

        if fname is None:
            # Dots might appear in the host part of the display name
            # during remote X sessions. Let's strip the host part first
            display_name = kore.display_name
            display_number = display_name.partition(":")[2]
            if "." not in display_number:
                display_name += ".0"
            fname = ipc.find_sockfile(display_name)

        if os.path.exists(fname):
            os.unlink(fname)
        self.server = ipc.Server(fname, self.qtile.server.call, eventloop)