Пример #1
0
    def __init__(self, i3conn):
        # i3ipc connection, bypassed by negi3wm runner
        self.i3ipc = i3conn
        self.panel_should_be_restored = False

        # Initialize modcfg.
        cfg.__init__(self, i3conn)

        # default panel classes
        self.panel_classes = self.cfg.get("panel_classes", [])

        # fullscreened workspaces
        self.ws_fullscreen = self.cfg.get("ws_fullscreen", [])

        # for which windows we shoudn't show panel
        self.classes_to_hide_panel = self.cfg.get("classes_to_hide_panel", [])

        self.show_panel_on_close = False

        self.bindings = {
            "reload": self.reload_config,
            "fullscreen": self.hide,
        }

        self.i3ipc.on('window::close', self.on_window_close)
        self.i3ipc.on('workspace::focus', self.on_workspace_focus)
Пример #2
0
    def __init__(self, i3) -> None:
        """ Init function

        Args:
            i3: i3ipc connection
        """
        # Initialize cfg.
        cfg.__init__(self, i3)

        # i3ipc connection, bypassed by negi3wm runner
        self.i3ipc = i3

        # previous / current window list
        self.window_history = []

        # depth of history list
        self.max_win_history = 4

        # workspaces with auto alt-tab when close
        self.autoback = self.conf('autoback')

        self.bindings = {
            "switch": self.alt_tab,
            "reload": self.reload_config,
            "focus_next": self.focus_next,
            "focus_prev": self.focus_prev,
            "focus_next_visible": self.focus_next_visible,
            "focus_prev_visible": self.focus_prev_visible,
        }

        self.i3ipc.on('window::focus', self.on_window_focus)
        self.i3ipc.on('window::close', self.goto_nonempty_ws_on_close)
Пример #3
0
    def __init__(self, i3) -> None:
        """ Init function

        Args:
            i3: i3ipc connection
        """
        # Initialize superclasses.
        cfg.__init__(self, i3)
        Matcher.__init__(self)

        # Initialization

        # winlist is used to reduce calling i3.get_tree() too many times.
        self.win = None

        # fullscreen_list is used to perform fullscreen hacks
        self.fullscreen_list = []

        # nsgeom used to respect current screen resolution in the geometry
        # settings and scale it
        self.nsgeom = geom.geom(self.cfg)

        # marked used to get the list of current tagged windows
        # with the given tag
        self.marked = {l: [] for l in self.cfg}

        # Mark all tags from the start
        self.mark_all_tags(hide=True)

        # Do not autosave geometry by default
        self.auto_save_geom(False)

        # focus_win_flag is a helper to perform attach/detach window to the
        # named scratchpad with add_prop/del_prop routines
        self.focus_win_flag = [False, ""]

        # i3ipc connection, bypassed by negi3wm runner
        self.i3ipc = i3

        self.bindings = {
            "show": self.show_scratchpad,
            "hide": self.hide_scratchpad_all_but_current,
            "next": self.next_win_on_curr_tag,
            "toggle": self.toggle,
            "hide_current": self.hide_current,
            "geom_restore": self.geom_restore_current,
            "geom_dump": self.geom_dump_current,
            "geom_save": self.geom_save_current,
            "geom_autosave": self.autosave_toggle,
            "subtag": self.run_subtag,
            "add_prop": self.add_prop,
            "del_prop": self.del_prop,
            "reload": self.reload_config,
            "dialog": self.dialog_toggle,
        }

        i3.on('window::new', self.mark_tag)
        i3.on('window::close', self.unmark_tag)
Пример #4
0
 def __init__(self, i3) -> None:
     cfg.__init__(self, i3)
     self.i3ipc = i3
     self.bindings = {
         "print": self.print,
         "dump": self.dump_cfg,
         "reload": self.reload_config,
     }
     self.send_path = '${XDG_CONFIG_HOME}/i3/bin/send'
Пример #5
0
    def __init__(self, i3) -> None:
        """ Init function

        Main part is in self.initialize, which performs initialization itself.

        Attributes:
            i3: i3ipc connection
        """
        # Initialize cfg.
        cfg.__init__(self, i3)
        # i3ipc connection, bypassed by negi3wm runner.
        self.i3ipc = i3
        self.i3ipc.on("window::focus", self.auto_tiling)

        # cache list length
        maxlength = self.conf("cache_list_size")

        # create list with the finite number of elements by the [None] * N hack
        self.geom_list = collections.deque([None] * maxlength,
                                           maxlen=maxlength)

        # we need to know current resolution for almost all operations here.
        self.current_resolution = Display.get_screen_resolution()

        # here we load information about useless gaps
        self.load_useless_gaps()

        # config about useless gaps for quad splitting, True by default
        self.quad_use_gaps = self.conf("quad_use_gaps")

        # config about useless gaps for half splitting, True by default
        self.x2_use_gaps = self.conf("x2_use_gaps")

        # coeff to grow window in all dimensions
        self.grow_coeff = self.conf("grow_coeff")

        # coeff to shrink window in all dimensions
        self.shrink_coeff = self.conf("shrink_coeff")

        self.bindings = {
            "reload": self.reload_config,
            "maximize": self.maximize,
            "maxhor": lambda: self.maximize(by='X'),
            "maxvert": lambda: self.maximize(by='Y'),
            "x2": self.x2,
            "x4": self.quad,
            "quad": self.quad,
            "grow": self.grow,
            "shrink": self.shrink,
            "center": self.move_center,
            "revert_maximize": self.revert_maximize,
            "resize": self.resize,
            "tab-focus": self.focus_tab,
            "tab-move": self.move_tab,
            "next_ws": self.next_ws,
        }
Пример #6
0
    def __init__(self, i3) -> None:
        # Initialize cfg.
        cfg.__init__(self, i3)

        # i3ipc connection, bypassed by negi3wm runner.
        self.i3ipc = i3

        # Default increment step for mpd.
        self.inc = self.conf("mpd_inc")

        # Default mpd address.
        self.mpd_addr = self.conf("mpd_addr")

        # Default mpd port.
        self.mpd_port = self.conf("mpd_port")

        # Default mpd buffer size.
        self.mpd_buf_size = self.conf("mpd_buf_size")

        # Default mpv socket.
        self.mpv_socket = self.conf("mpv_socket")

        # Send 0, 9 keys to the mpv window or not.
        self.use_mpv09 = self.conf("use_mpv09")

        # Define mpd socket
        self.mpd_socket = None

        # Cache current window on focus.
        self.i3ipc.on("window::focus", self.set_curr_win)

        # Default mpd status is False
        self.mpd_playing = False

        # MPD idle command listens to the player events by default.
        self.idle_cmd_str = "idle player\n"

        # MPD status string, which we need send to extract most of information.
        self.status_cmd_str = "status\n"

        self.bindings = {
            "u": self.volume_up,
            "d": self.volume_down,
            "mute": self.volume_mute,
            "max": self.volume_max,
            "reload": self.reload_config,
        }

        # Initial state for the current_win
        self.current_win = self.i3ipc.get_tree().find_focused()
Пример #7
0
    def __init__(self, i3) -> None:
        """ Init function. """
        cfg.__init__(self, i3)
        self.envs = {}
        for app in self.cfg:
            self.envs[app] = env(app, self.cfg)

        self.bindings = {
            "run": self.run,
            "reload": self.reload_config,
        }

        self.i3 = i3
        self.env = None
Пример #8
0
    def __init__(self, i3ipc) -> None:
        # Initialize cfg.
        cfg.__init__(self, i3ipc)

        # i3ipc connection, bypassed by negi3wm runner
        self.i3ipc = i3ipc

        # i3 path used to get "send" binary path
        self.i3_path = Misc.i3path()

        # i3-msg application name
        self.i3cmd = self.conf("i3cmd")

        # Window properties shown by xprop menu.
        self.xprops_list = self.conf("xprops_list")

        # cache screen width
        if not self.conf("use_default_width"):
            from display import Display
            self.screen_width = Display.get_screen_resolution()["width"]
        else:
            self.screen_width = int(self.conf('use_default_width'))

        for mod in self.cfg['modules']:
            module = importlib.import_module('menu_mods.' + mod)
            setattr(self, mod, getattr(module, mod)(self))

        self.bindings = {
            "cmd_menu": self.i3menu.cmd_menu,
            "xprop": self.xprop.xprop,
            "autoprop": self.props.autoprop,
            "show_props": self.props.show_props,
            "pulse_output": self.pulse_menu.pulseaudio_output,
            "pulse_input": self.pulse_menu.pulseaudio_input,
            "pulse_mute": self.pulse_menu.pulseaudio_mute,
            "ws": self.winact.goto_ws,
            "goto_win": self.winact.goto_win,
            "attach": self.winact.attach_win,
            "movews": self.winact.move_to_ws,
            "gtk_theme": self.gnome.change_gtk_theme,
            "icon_theme": self.gnome.change_icon_theme,
            "xrandr_resolution": self.xrandr.change_resolution_xrandr,
            "reload": self.reload_config,
        }
Пример #9
0
    def __init__(self, i3) -> None:
        """ Init function

        Main part is in self.initialize, which performs initialization itself.

        Args:
            i3: i3ipc connection
        """
        # Initialize superclasses.
        cfg.__init__(self, i3)
        Matcher.__init__(self)

        # i3ipc connection, bypassed by negi3wm runner.
        self.i3ipc = i3

        # map of tag to the tagged windows.
        self.tagged = {}

        # current_position for the tag [tag]
        self.current_position = {}

        # list of windows which fullscreen state need to be restored.
        self.restore_fullscreen = []

        # is the current action caused by user actions or not? It's needed for
        # corrent fullscreen on/off behaviour.
        self.interactive = True

        # how many attempts taken to find window with priority
        self.repeats = 0

        # win cache for the fast matching
        self.win = None

        # used for subtag info caching
        self.subtag_info = {}

        # Should the special fullscreen-related actions to be performed or not.
        self.need_handle_fullscreen = True

        # Initialize
        i3tree = self.i3ipc.get_tree()

        # prepare for prefullscreen
        self.fullscreened = i3tree.find_fullscreen()

        # store the current window here to cache get_tree().find_focused value.
        self.current_win = i3tree.find_focused()

        # winlist is used to reduce calling i3.get_tree() too many times.
        self.winlist = i3tree.leaves()
        for tag in self.cfg:
            self.tagged[tag] = []
            self.current_position[tag] = 0

        # tag all windows after start
        self.tag_windows(invalidate_winlist=False)

        self.bindings = {
            "next": self.go_next,
            "subtag": self.go_subtag,
            "add_prop": self.add_prop,
            "del_prop": self.del_prop,
            "reload": self.reload_config,
        }

        self.i3ipc.on('window::new', self.add_wins)
        self.i3ipc.on('window::close', self.del_wins)
        self.i3ipc.on("window::focus", self.set_curr_win)
        self.i3ipc.on("window::fullscreen_mode", self.handle_fullscreen)