dflock / ulauncher-window-switcher

Linux/X11 Window Switcher plugin for Ulauncher
GNU General Public License v3.0
14 stars 10 forks source link

Loading... #2

Closed abers closed 2 years ago

abers commented 3 years ago

I am using Ulauncher v5.10.0 on Kubuntu 20,04 with i3-gaps as the window manager.

When trying to switch windows and after typing 'win ' ulauncher displays a single item 'Loading...' - but nothing ever loads. No entries are made in the logs so I am unsure what is causing the issue.

dflock commented 3 years ago

You need wmctrl installed - do you have it?

$ wmctrl --version
1.07
abers commented 3 years ago

Yep - version 1.07

axgkl commented 3 years ago

same problem hier, wmctrl version 1.07. WM is dwm. Distri Fedora 32.

/home/gk$ wmctrl -l
0x01800006  1 gkfedora gk@gkfedora [1] /home/gk
0x01a00005  4 gkfedora Loading... · Issue #2 · dflock/ulauncher-window-switcher - Google Chrome
(...)
axgkl commented 3 years ago

Ok, I logged some output of your main.py (in $HOME/.local/share/ulauncher/extensions/com.github.dflock.ulauncher-window-switcher):

Problem is that on my dwm this is not delivering what you expect:

        # Get list of all workspaces and process into a dictionary that looks like this:
        # {<workspace_id>: <workspace_name>}
        result = subprocess.run(
            ['wmctrl -d | awk \'{$1=$2=$3=$4=$5=$6=$7=$8=$9=""; print $0}\''],
            capture_output=True,
            shell=True,
            text=True,
        ).stdout

On my system wmctrl -d delivers 511 lines, matching their tag combinations (they don't have classic workspaces) - and none matches the w_dict. So I just omit the workspace info and all is fine:

        # Get list of all workspaces and process into a dictionary that looks like this:
        # {<workspace_id>: <workspace_name>}
        # result = subprocess.run(
        #     ['wmctrl -d | awk \'{$1=$2=$3=$4=$5=$6=$7=$8=$9=""; print $0}\''],
        #     capture_output=True,
        #     shell=True,
        #     text=True,
        # ).stdout
        # ws_list = [y for y in (x.strip() for x in result.splitlines()) if y]
        # ws_dict = {i: x for i, x in enumerate(ws_list)}

        for w_idx, window in w_dict.items():
            if search == '' or search in window['name'].lower():
                items.append(
                    ExtensionResultItem(
                        icon='images/window.svg',
                        # Workaround for https://github.com/Ulauncher/Ulauncher/issues/587
                        name=window['name'].replace('&', '&amp;')
                        if search
                        else window['name'],
                        description=f'Workspace: {window["ws"]}, Window Id: {w_idx}',
                        on_enter=RunScriptAction(f'wmctrl -ia {w_idx}'),
                    )
             )       

Not sure how you could autodetect and remember that though, you would need global state or a tempfile, where you flag if ws_list is empty or so... I guess a config setting resolve_workspace_names default true would be the most robust answer.

dflock commented 3 years ago

Could you post the output of wmctrl -d on your system - or some of it, at least?

furgerf commented 3 years ago

Same issue for me with awesomewm and fancy workspace names. My workspaces are, according to wmctrl -d:

0  - DG: N/A  VP: N/A  WA: N/A  ~
1  * DG: N/A  VP: N/A  WA: N/A  ~
2  - DG: N/A  VP: N/A  WA: N/A  ➋ ·web·🌏
3  - DG: N/A  VP: N/A  WA: N/A  ➐ ·foo
4  - DG: N/A  VP: N/A  WA: N/A  ➎ ·media·♫

This gets parsed as ws_dict = {0: '·web·🌏', 1: '·foo', 2: '·media·♫'} - seems like awk is cutting off too much. For me it works properly when I remove the $9= (giving me ws_dict = {0: '~', 1: '~', 2: '➋ ·web·🌏', 3: '➐ ·foo', 4: '➎ ·media·♫'}).

dflock commented 3 years ago

This is very helpful, thank you! I'm just about to go on vacation, but will be back in a week and will have a go at fixing this then - if no one else fixes it first ;)

furgerf commented 3 years ago

Sure, I can submit a PR. Sounds like wmctrl isn't entirely sticking to its documentation:

List all desktops managed by the window manager. One line is output for each desktop, with the line broken up into spacce separated columns. The first column contains an integer desktop number. The second column contains a '*' character for the current desktop, otherwise it contains a '-' character. The next two columns contain the fixed string DG: and then the desktop geometry as 'x' (e.g. '1280x1024'). The following two columns contain the fixed string VP: and then the viewport position in the format ',' (e.g. '0,0'). The next three columns after this contains the fixed string WA: and then two columns with the workarea geometry as 'X,Y and WxH' (e.g. '0,0 1280x998'). The rest of the line contains the name of the desktop (possibly containing multiple spaces).

In my case, because no workarea is available, there's one less column. I'm not that fluent with awk and would probably move this (more complex) parsing to the python code.

Thanks for providing this extension and enjoy your holiday - hopefully somewhere a bit colder!

dflock commented 2 years ago

This is fixed by @furgerf and myself in #7 - thanks everyone for your help & patience.