コード例 #1
0
    def autoprop(self) -> None:
        """ Start autoprop menu to move current module to smth. """
        mod = self.get_mod()
        if mod is None or not mod:
            return

        aprop_str = self.get_autoprop_as_str(with_title=False)
        tag_name = self.tag_name(mod, props.mod_data_list(mod))
        if tag_name is not None and tag_name:
            extension.get_mods()[mod].add_prop(tag_name, aprop_str)
        else:
            print(f'No tag name specified for props {aprop_str}')
コード例 #2
0
    def bscratch_bindings(self, mode) -> str:
        ret = ''
        def get_binds(mode, tag, settings, p, subtag='') -> str:
            ret = ''
            pref, postfix = '', ''
            if mode != 'default':
                pref, postfix = '\t', ',$exit'
            get_binds = p.split('_')
            mode_ = get_binds[1]
            cmd = get_binds[2]
            if len(get_binds) == 3:
                if mode_ == mode:
                    for keybind in settings[p]:
                        ret += f'{pref.strip()}bindsym {keybind.strip()}' \
                            f' $bscratch {cmd.strip()} {tag.strip()} ' \
                            f'{subtag.strip()} {postfix.strip()}\n'
            return ret

        bscratch = extension.get_mods()['bscratch']
        for tag,settings in bscratch.cfg.items():
            for param in settings:
                if isinstance(settings[param], dict):
                    for p in settings[param]:
                        if p.startswith('keybind_'):
                            subtag = param
                            ret += get_binds(
                                mode, tag, settings[param], p, subtag=subtag
                            )
                elif param.startswith('keybind_'):
                    ret += get_binds(mode, tag, settings, param)
        return ret
コード例 #3
0
    def circle_bindings(self, mode) -> str:
        ret = ''
        def get_binds(mode, tag, settings, p, subtag='') -> str:
            ret = ''
            pref, postfix = '', ''
            if mode != 'default':
                pref, postfix = '\t', ',$exit'
            get_binds = p.split('_')
            mode_ = get_binds[1]
            cmd = get_binds[2]
            if len(get_binds) == 3:
                if mode_ == mode:
                    for keybind in settings[p]:
                        ret += f'{pref}bindsym {keybind} $circle' \
                            f' {cmd} {tag} {subtag} {postfix}\n'
            return ret

        circle = extension.get_mods()['circle']
        for tag, settings in circle.cfg.items():
            for param in settings:
                if isinstance(settings[param], dict):
                    for p in settings[param]:
                        if p.startswith('keybind_'):
                            subtag = param
                            ret += get_binds(
                                mode, tag, settings[subtag], p, subtag
                            )
                elif param.startswith('keybind_'):
                    ret += get_binds(mode, tag, settings, param)
        return ret
コード例 #4
0
    def toggle(self, tag: str) -> None:
        """ Toggle scratchpad with given [tag].

            Args:
                tag (str): denotes the target tag.
        """
        if not self.marked.get(tag, []):
            prog_str = self.extract_prog_str(self.conf(tag))
            if prog_str:
                self.i3ipc.command(f'exec {prog_str}')
            else:
                spawn_str = self.extract_prog_str(
                    self.conf(tag), "spawn", exe_file=False
                )
                if spawn_str:
                    executor = extension.get_mods().get('executor')
                    if executor is not None:
                        executor.bindings['run'](spawn_str)

        if self.visible_window_with_tag(tag):
            self.hide_scratchpad(tag)
            return

        # We need to hide scratchpad it is visible,
        # regardless it focused or not
        focused = self.i3ipc.get_tree().find_focused()

        if self.marked.get(tag, []):
            self.toggle_fs(focused)
            self.show_scratchpad(tag)
コード例 #5
0
 def rules_mod(modname):
     """ Create i3 match rules for all tags. """
     ret = ''
     mod = extension.get_mods().get(modname, None)
     if mod is None:
         return ''
     cmd_dict = fill_rules_dict(mod, {})
     for tag in cmd_dict:
         rules = list(filter(lambda str: str != '', cmd_dict[tag]))
         if rules:
             ret += f'set ${modname}-{tag} [' + ' '.join(rules) + ']'
             ret += '\n'
     return (ret, cmd_dict, mod)
コード例 #6
0
ファイル: winact.py プロジェクト: snide/negi3wm
 def select_ws(self) -> str:
     """ Apply target function to workspace. """
     ws_list = extension.get_mods()['i3cfg'].cfg['ws_list']
     menu_params = {
         'cnum': len(ws_list),
         'width': int(self.menu.screen_width * 0.66),
         'prompt': f'{self.menu.wrap_str("ws")} {self.menu.conf("prompt")}',
     }
     try:
         workspace_name = subprocess.run(self.menu.args(menu_params),
                                         stdout=subprocess.PIPE,
                                         input=bytes(
                                             '\n'.join(ws_list), 'UTF-8'),
                                         check=False).stdout
         selected_ws = workspace_name.decode('UTF-8').strip()
         if selected_ws:
             num = ws_list.index(selected_ws) + 1
             return str(f'{num} :: {selected_ws}')
     except Exception:
         return ''
     return ''
コード例 #7
0
ファイル: circle.py プロジェクト: snide/negi3wm
    def run_prog(self, tag: str, subtag: str = '') -> None:
        """ Run the appropriate application for the current tag/subtag.

        Args:
            tag (str): denotes target [tag]
            subtag (str): denotes the target [subtag], optional.
        """
        if tag is not None and self.cfg.get(tag) is not None:
            if not subtag:
                prog_str = self.extract_prog_str(self.conf(tag))
            else:
                prog_str = self.extract_prog_str(
                    self.conf(tag, subtag)
                )
            if prog_str:
                self.i3ipc.command(f'exec {prog_str}')
            else:
                spawn_str = self.extract_prog_str(
                    self.conf(tag), "spawn", exe_file=False
                )
                if spawn_str:
                    executor = extension.get_mods().get('executor')
                    if executor is not None:
                        executor.bindings['run'](spawn_str)
コード例 #8
0
ファイル: circle.py プロジェクト: snide/negi3wm
 def focus_driven_actions(self, tag):
     """ Make some actions after focus """
     if self.conf(tag, "mpd_shut") == 1:
         vol = extension.get_mods().get('vol')
         if vol is not None:
             vol.bindings['mute']()
コード例 #9
0
 def mods_commands(self) -> str:
     ret = ''
     for mod in sorted(extension.get_mods()):
         ret += (f'set ${mod} exec --no-startup-id {self.send_path} {mod}\n')
     return ret
コード例 #10
0
 def mod_data_list(mod: str) -> List[str]:
     """ Extract list of module tags. Used by add_prop menus.
         mod (str): extension name. """
     return extension.get_mods()[mod].cfg.keys()