albertlauncher / albert

A fast and flexible keyboard launcher
https://albertlauncher.github.io
Other
7.29k stars 307 forks source link

Window Switcher does not work if heidisql is running #1034

Closed KuenzelIT closed 3 years ago

KuenzelIT commented 3 years ago

Description I'm using HeidiSQL with wine. Whenever it runs, the window switcher is not working. I found that out by looking at wmctrl -l -x and seeing that the output differed for heidisql. Here is a part of the output:

0x07e06bea  0 gnome-terminal-server.Gnome-terminal  dkthink dk@dkthink: ~
0x09600004  0 heidisql.exe.heidisql.exe  dkthink

It seems like the missing title is leading to this error:

14:58:55 [warn:python.modulev1] [window_switcher] ValueError: not enough values to unpack (expected 2, got 1)

At:
  /usr/share/albert/org.albert.extension.python/modules/window_switcher/__init__.py(52): parseWindow
  /usr/share/albert/org.albert.extension.python/modules/window_switcher/__init__.py(23): handleQuery

Expected behavior Window switching should still be possible if I run heidisql with wine.

Steps to reproduce Install HeidiSQL using wine, run it and try to switch to another window

Screenshots None

Additional information (please provide the following information):

(Source: e.g. ppa:name, repository, built from source, etc …)

Output of `albert --report ` core: Albert version: 0.17.2 core: Build date: Oct 29 2017 00:00:00 core: Qt version: 5.12.8 core: QT_QPA_PLATFORMTHEME: qt5ct core: Binary location: /usr/bin/albert core: PWD: /home/dk core: SHELL: /bin/bash core: LANG: de_DE.UTF-8 core: XDG_SESSION_TYPE: x11 core: XDG_CURRENT_DESKTOP: X-Cinnamon core: DESKTOP_SESSION: cinnamon core: XDG_SESSION_DESKTOP: cinnamon core: OS: Linux Mint 20.1 core: OS (type/version): linuxmint/20.1 core: Build ABI: x86_64-little_endian-lp64 core: Arch (build/current): x86_64/x86_64 core: Kernel (type/version): linux/5.4.0-72-generic
Output of `albert` when started in a terminal (stdout/stderr) 15:04:33 [info:core] Initializing application 15:04:33 [debg:qt5ct] using qt5ct plugin 15:04:33 [info:default] Systems icon theme is: "Mint-Y" 15:04:33 [info:core] Initializing mandatory paths 15:04:33 [info:core] Setup signal handlers 15:04:33 [info:core] Creating running indicator file 15:04:33 [info:core] Initializing core components 15:04:33 [info:core] Loading extension org.albert.extension.applications 15:04:33 [info:apps] Start indexing applications. 15:04:33 [debg:core] org.albert.extension.applications loaded in 1 milliseconds 15:04:33 [info:core] Loading extension org.albert.extension.calculator 15:04:33 [debg:core] org.albert.extension.calculator loaded in 2 milliseconds 15:04:33 [info:core] Loading extension org.albert.extension.files 15:04:33 [debg:applications] Loading file index from cache. 15:04:33 [debg:applications] Building inverted file index. 15:04:33 [debg:apps] Indexing desktop file: alacarte-made-15c10b12-6c49-11eb-a497-b781173acaa0.desktop 15:04:33 [debg:apps] Indexing desktop file: alacarte-made-3c9230e2-6bf2-11eb-b9d9-cfbfce32aa83.desktop 15:04:33 [info:applications] Start indexing files. 15:04:33 [debg:core] org.albert.extension.files loaded in 10 milliseconds 15:04:33 [info:core] Loading extension org.albert.extension.firefoxbookmarks 15:04:33 [info:firefox] Start indexing Firefox bookmarks. 15:04:33 [debg:core] org.albert.extension.firefoxbookmarks loaded in 1 milliseconds 15:04:33 [info:core] Loading extension org.albert.extension.hashgenerator 15:04:33 [debg:applications] Serializing files… 15:04:33 [debg:applications] Building inverted file index… 15:04:33 [debg:core] org.albert.extension.hashgenerator loaded in 15 milliseconds 15:04:33 [info:core] Loading extension org.albert.extension.python 15:04:33 [debg:apps] Indexing desktop file: alacarte-made-87a14602-6ba4-11eb-b9d9-cfbfce32aa83.desktop 15:04:33 [debg:apps] Indexing desktop file: alacarte-made-e311eb00-7c60-11eb-ab21-17def5bf8fbb.desktop 15:04:33 [debg:apps] Indexing desktop file: albert.desktop 15:04:33 [warn:default] QFileSystemWatcher::removePaths: list is empty 15:04:33 [debg:apps] Indexing desktop file: apturl.desktop 15:04:33 [debg:apps] Indexing desktop file: audacity.desktop 15:04:33 [debg:python.modulev1] Reading metadata of python module: api_test 15:04:33 [debg:apps] Indexing desktop file: blueberry.desktop 15:04:33 [debg:apps] Indexing desktop file: bluetooth-sendto.desktop 15:04:33 [debg:apps] Indexing desktop file: chromium-browser.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-color-panel.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-display-panel.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-killer-daemon.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-menu-editor.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-network-panel.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-onscreen-keyboard.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-region-panel.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-screensaver.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-applets.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-backgrounds.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-calendar.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-default.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-desklets.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-desktop.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-effects.desktop 15:04:33 [debg:python.modulev1] Reading metadata of python module: arch_wiki 15:04:33 [debg:python.modulev1] Reading metadata of python module: atom_projects 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-extensions.desktop 15:04:33 [info:python.modulev1] Could not locate python module 'cson'. 15:04:33 [debg:python.modulev1] Reading metadata of python module: aur 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-fonts.desktop 15:04:33 [debg:python.modulev1] Reading metadata of python module: base_converter 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-general.desktop 15:04:33 [info:python.modulev1] Could not locate python module 'numpy'. 15:04:33 [debg:python.modulev1] Reading metadata of python module: binance 15:04:33 [info:python.modulev1] Loading /usr/share/albert/org.albert.extension.python/modules/binance 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-hotcorner.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-info.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-keyboard.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-mouse.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-notifications.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-online-accounts.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-panel.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-power.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-privacy.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-screensaver.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-sound.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-startup.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-themes.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-tiling.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-universal-access.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-user.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-users.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-windows.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings-workspaces.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-settings.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon-wacom-panel.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon.desktop 15:04:33 [debg:apps] Indexing desktop file: cinnamon2d.desktop 15:04:33 [debg:apps] Indexing desktop file: com.github.maoschanz.drawing.desktop 15:04:33 [debg:apps] Indexing desktop file: com.nextcloud.desktopclient.nextcloud.desktop 15:04:33 [debg:apps] Indexing desktop file: csd-automount.desktop 15:04:33 [debg:apps] Indexing desktop file: display-im6.q16.desktop 15:04:33 [debg:python.modulev1] Reading metadata of python module: bitwarden 15:04:33 [info:python.modulev1] No 'rbw' in $PATH. 15:04:33 [debg:python.modulev1] Reading metadata of python module: copyq 15:04:33 [info:python.modulev1] No 'copyq' in $PATH. 15:04:33 [debg:python.modulev1] Reading metadata of python module: currency_converter 15:04:33 [info:python.modulev1] Loading /usr/share/albert/org.albert.extension.python/modules/currency_converter 15:04:33 [debg:python.modulev1] Reading metadata of python module: datetime 15:04:33 [debg:apps] Indexing desktop file: element-desktop.desktop 15:04:33 [debg:apps] Indexing desktop file: firefox.desktop 15:04:33 [info:python.modulev1] Loading /usr/share/albert/org.albert.extension.python/modules/datetime 15:04:33 [debg:apps] Indexing desktop file: gcr-prompter.desktop 15:04:33 [debg:apps] Indexing desktop file: gcr-viewer.desktop 15:04:33 [debg:apps] Indexing desktop file: gdebi.desktop 15:04:33 [debg:apps] Indexing desktop file: geoclue-demo-agent.desktop 15:04:33 [debg:python.modulev1] Reading metadata of python module: docker 15:04:33 [debg:apps] Indexing desktop file: gkbd-keyboard-display.desktop 15:04:33 [debg:apps] Indexing desktop file: gnome-disk-image-mounter.desktop 15:04:33 [debg:apps] Indexing desktop file: gnome-disk-image-writer.desktop 15:04:33 [debg:apps] Indexing desktop file: gnome-system-monitor-kde.desktop 15:04:33 [debg:apps] Indexing desktop file: gnome-system-monitor.desktop 15:04:33 [info:python.modulev1] Could not locate python module 'docker'. 15:04:33 [debg:python.modulev1] Reading metadata of python module: fortune 15:04:33 [info:python.modulev1] No 'fortune' in $PATH. 15:04:33 [debg:python.modulev1] Reading metadata of python module: gnome_dictionary 15:04:33 [debg:apps] Indexing desktop file: gnote.desktop 15:04:33 [info:python.modulev1] No 'gnome-dictionary' in $PATH. 15:04:33 [debg:python.modulev1] Reading metadata of python module: gnote 15:04:33 [debg:apps] Indexing desktop file: gucharmap.desktop 15:04:33 [debg:python.modulev1] Reading metadata of python module: goldendict 15:04:33 [debg:apps] Indexing desktop file: gufw.desktop 15:04:33 [info:python.modulev1] No 'goldendict' in $PATH. 15:04:33 [debg:python.modulev1] Reading metadata of python module: google_translate 15:04:33 [debg:apps] Indexing desktop file: hedgewars.desktop 15:04:33 [debg:python.modulev1] Reading metadata of python module: ip 15:04:33 [info:python.modulev1] Loading /usr/share/albert/org.albert.extension.python/modules/ip 15:04:33 [debg:python.modulev1] Reading metadata of python module: jetbrains_projects 15:04:33 [warn:python.modulev1] [jetbrains_projects] Invalid version format: ''. Expected '^(\d)\.(\d)\.(\d)$'. 15:04:33 [debg:python.modulev1] Reading metadata of python module: kill 15:04:33 [debg:python.modulev1] Reading metadata of python module: locate 15:04:33 [debg:python.modulev1] Reading metadata of python module: lpass 15:04:33 [info:python.modulev1] No 'lpass' in $PATH. 15:04:33 [debg:python.modulev1] Reading metadata of python module: mathematica_eval 15:04:33 [info:python.modulev1] No 'wolframscript' in $PATH. 15:04:33 [debg:python.modulev1] Reading metadata of python module: multi_google_translate 15:04:33 [debg:python.modulev1] Reading metadata of python module: node_eval 15:04:33 [debg:python.modulev1] Reading metadata of python module: npm 15:04:33 [debg:python.modulev1] Reading metadata of python module: packagist 15:04:33 [debg:python.modulev1] Reading metadata of python module: pacman 15:04:33 [info:python.modulev1] No 'expac' in $PATH. 15:04:33 [debg:python.modulev1] Reading metadata of python module: pass 15:04:33 [info:python.modulev1] No 'pass' in $PATH. 15:04:33 [debg:python.modulev1] Reading metadata of python module: php_eval 15:04:33 [debg:python.modulev1] Reading metadata of python module: pidgin 15:04:33 [info:python.modulev1] No 'python' in $PATH. 15:04:33 [debg:python.modulev1] Reading metadata of python module: pomodoro 15:04:33 [debg:python.modulev1] Reading metadata of python module: python_eval 15:04:33 [debg:python.modulev1] Reading metadata of python module: remmina 15:04:33 [warn:python.modulev1] [remmina] Incompatible minor interface version. Up to 4 supported, got 5. Maybe you should update albert. 15:04:33 [info:python.modulev1] Loading /usr/share/albert/org.albert.extension.python/modules/remmina 15:04:33 [debg:apps] Indexing desktop file: hplj1020.desktop 15:04:33 [debg:apps] Indexing desktop file: htop.desktop 15:04:33 [debg:apps] Indexing desktop file: im-config.desktop 15:04:33 [debg:apps] Indexing desktop file: info.desktop 15:04:33 [debg:apps] Indexing desktop file: io.github.Hexchat.desktop 15:04:33 [debg:apps] Indexing desktop file: io.github.celluloid_player.Celluloid.desktop 15:04:33 [debg:python.modulev1] Reading metadata of python module: scrot 15:04:33 [info:python.modulev1] No 'xclip' in $PATH. 15:04:33 [debg:python.modulev1] Reading metadata of python module: tex_to_unicode 15:04:33 [info:python.modulev1] Could not locate python module 'pylatexenc'. 15:04:33 [debg:python.modulev1] Reading metadata of python module: texdoc 15:04:33 [info:python.modulev1] No 'texdoc' in $PATH. 15:04:33 [debg:python.modulev1] Reading metadata of python module: timer 15:04:33 [debg:python.modulev1] Reading metadata of python module: tomboy 15:04:33 [info:python.modulev1] No 'tomboy' in $PATH. 15:04:33 [debg:python.modulev1] Reading metadata of python module: trash 15:04:33 [debg:python.modulev1] Reading metadata of python module: unicode_emoji 15:04:33 [debg:python.modulev1] Reading metadata of python module: units 15:04:33 [info:python.modulev1] No 'units' in $PATH. 15:04:33 [debg:python.modulev1] Reading metadata of python module: vpn 15:04:33 [debg:python.modulev1] Reading metadata of python module: wikipedia 15:04:33 [debg:python.modulev1] Reading metadata of python module: window_switcher 15:04:33 [info:python.modulev1] Loading /usr/share/albert/org.albert.extension.python/modules/window_switcher 15:04:33 [debg:python.modulev1] Reading metadata of python module: xkcd 15:04:33 [warn:python.modulev1] [xkcd] Invalid version format: ''. Expected '^(\d)\.(\d)\.(\d)$'. 15:04:33 [debg:python.modulev1] Reading metadata of python module: youtube 15:04:33 [debg:python.modulev1] Reading metadata of python module: zeal 15:04:33 [info:python.modulev1] No 'zeal' in $PATH. 15:04:33 [debg:core] org.albert.extension.python loaded in 265 milliseconds 15:04:33 [info:core] Loading extension org.albert.extension.ssh 15:04:33 [debg:apps] Indexing desktop file: kde4-mintbackup.desktop 15:04:33 [debg:apps] Indexing desktop file: kde4-mintdrivers.desktop 15:04:33 [debg:apps] Indexing desktop file: kde4-mintreport.desktop 15:04:33 [debg:apps] Indexing desktop file: kde4-mintwelcome.desktop 15:04:33 [debg:apps] Indexing desktop file: kde4-webapp-manager.desktop 15:04:33 [debg:apps] Indexing desktop file: libreoffice-base.desktop 15:04:33 [debg:apps] Indexing desktop file: libreoffice-calc.desktop 15:04:33 [debg:apps] Indexing desktop file: libreoffice-draw.desktop 15:04:33 [debg:apps] Indexing desktop file: libreoffice-impress.desktop 15:04:33 [debg:apps] Indexing desktop file: libreoffice-math.desktop 15:04:33 [debg:apps] Indexing desktop file: libreoffice-startcenter.desktop 15:04:33 [debg:apps] Indexing desktop file: libreoffice-writer.desktop 15:04:33 [debg:apps] Indexing desktop file: libreoffice-xsltfilter.desktop 15:04:33 [debg:apps] Indexing desktop file: lightdm-settings.desktop 15:04:33 [debg:apps] Indexing desktop file: mate-about.desktop 15:04:33 [debg:apps] Indexing desktop file: mate-color-select.desktop 15:04:33 [debg:apps] Indexing desktop file: mate-panel.desktop 15:04:33 [debg:apps] Indexing desktop file: metacity.desktop 15:04:33 [debg:apps] Indexing desktop file: mint-meta-codecs.desktop 15:04:33 [debg:apps] Indexing desktop file: mintbackup.desktop 15:04:33 [debg:apps] Indexing desktop file: mintdrivers.desktop 15:04:33 [debg:apps] Indexing desktop file: mintinstall-fp-handler.desktop 15:04:33 [debg:apps] Indexing desktop file: mintinstall-kde.desktop 15:04:33 [debg:apps] Indexing desktop file: mintinstall.desktop 15:04:33 [debg:apps] Indexing desktop file: mintlocale-im.desktop 15:04:33 [debg:apps] Indexing desktop file: mintlocale.desktop 15:04:33 [debg:apps] Indexing desktop file: mintreport-tray.desktop 15:04:33 [debg:apps] Indexing desktop file: mintreport.desktop 15:04:33 [debg:apps] Indexing desktop file: mintsources.desktop 15:04:33 [debg:apps] Indexing desktop file: mintstick-format-kde.desktop 15:04:33 [debg:apps] Indexing desktop file: mintstick-format.desktop 15:04:33 [debg:apps] Indexing desktop file: mintstick-kde.desktop 15:04:33 [debg:apps] Indexing desktop file: mintstick.desktop 15:04:33 [debg:apps] Indexing desktop file: mintupdate-kde.desktop 15:04:33 [debg:apps] Indexing desktop file: mintupdate.desktop 15:04:33 [debg:apps] Indexing desktop file: mintwelcome.desktop 15:04:33 [debg:apps] Indexing desktop file: muffin.desktop 15:04:33 [debg:apps] Indexing desktop file: nemo-autorun-software.desktop 15:04:33 [debg:apps] Indexing desktop file: nemo-autostart.desktop 15:04:33 [debg:apps] Indexing desktop file: nemo.desktop 15:04:33 [debg:apps] Indexing desktop file: nm-applet.desktop 15:04:33 [debg:apps] Indexing desktop file: nm-applet_mate.desktop 15:04:33 [debg:apps] Indexing desktop file: nm-connection-editor.desktop 15:04:33 [debg:apps] Indexing desktop file: onboard-settings.desktop 15:04:33 [debg:apps] Indexing desktop file: onboard.desktop 15:04:33 [debg:apps] Indexing desktop file: org.gnome.Calculator.desktop 15:04:33 [debg:apps] Indexing desktop file: org.gnome.Calendar.desktop 15:04:33 [debg:apps] Indexing desktop file: org.gnome.DiskUtility.desktop 15:04:33 [debg:apps] Indexing desktop file: org.gnome.Evolution-alarm-notify.desktop 15:04:33 [debg:apps] Indexing desktop file: org.gnome.FileRoller.desktop 15:04:33 [debg:apps] Indexing desktop file: org.gnome.Logs.desktop 15:04:33 [debg:apps] Indexing desktop file: org.gnome.PowerStats.desktop 15:04:33 [debg:apps] Indexing desktop file: org.gnome.Screenshot.desktop 15:04:33 [debg:core] org.albert.extension.ssh loaded in 85 milliseconds 15:04:33 [info:core] Loading extension org.albert.extension.snippets 15:04:33 [debg:apps] Indexing desktop file: org.gnome.Terminal.desktop 15:04:33 [debg:core] org.albert.extension.snippets loaded in 0 milliseconds 15:04:33 [info:core] Loading extension org.albert.extension.websearch 15:04:33 [debg:apps] Indexing desktop file: org.gnome.baobab.desktop 15:04:33 [debg:core] org.albert.extension.websearch loaded in 0 milliseconds 15:04:33 [debg:apps] Indexing desktop file: org.gnome.font-viewer.desktop 15:04:33 [debg:apps] Indexing desktop file: org.gnome.seahorse.Application.desktop 15:04:33 [debg:qt5ct] D-Bus system tray: yes 15:04:34 [debg:apps] Indexing desktop file: org.shotcut.Shotcut.desktop 15:04:34 [debg:apps] Indexing desktop file: org.x.Warpinator.desktop 15:04:34 [debg:apps] Indexing desktop file: pix-import.desktop 15:04:34 [debg:apps] Indexing desktop file: pix.desktop 15:04:34 [debg:apps] Indexing desktop file: python3.8.desktop 15:04:34 [debg:apps] Indexing desktop file: qt5ct.desktop 15:04:34 [warn:core] No terminal command set. Using gnome-terminal -- 15:04:34 [info:core] Checking last used version 15:04:34 [info:core] Creating IPC server 15:04:34 [info:core] Entering eventloop 15:04:34 [debg:apps] Indexing desktop file: simple-scan.desktop 15:04:34 [debg:apps] Indexing desktop file: synaptic.desktop 15:04:34 [debg:apps] Indexing desktop file: system-config-printer.desktop 15:04:34 [info:applications] Indexed 249 files in 66 directories. 15:04:34 [info:firefox] Indexed 320 Firefox bookmarks. 15:04:34 [debg:apps] Indexing desktop file: xdg-desktop-portal-gtk.desktop 15:04:34 [debg:apps] Indexing desktop file: xed.desktop 15:04:34 [debg:apps] Indexing desktop file: xreader.desktop 15:04:34 [debg:apps] Indexing desktop file: xviewer.desktop 15:04:34 [debg:apps] Indexing desktop file: yelp.desktop 15:04:34 [info:apps] Indexed 118 applications. 15:04:36 [info:python] Binance markets updated.
jason--liu commented 3 years ago

I have the same problem when wine is running! It seems that when wine is running, the application name is more than two parts, which is the problem.

mattermost.Mattermost                                                                                                                                                                         
google-chrome.Google-chrome                                                                                                                                                                   
google-chrome.Google-chrome                                                                                                                                                                   
gnome-terminal-server.Gnome-terminal                                                                                                                                                          
nemo.Nemo                                                                                                                                                                                     
netease-cloud-music.netease-cloud-music                                                                                                                                                       
wxwork.exe.Wine           /*******************/                                                                                                                                    
17:11:25 [warn:python.modulev1] [window_switcher] ValueError: too many values to unpack (expected 2)                                                                                          

At:                                                                                                                                                                                           
  /home/xxx/.local/share/albert/org.albert.extension.python/modules/window_switcher/__init__.py(28): handleQuery   

The error occurs at

win_instance, win_class = win.wm_class.replace(' ', '-').split('.')

I'm not familiar with Python, may be there is a workaround can solve this problem. @ManuelSchneid3r

KuenzelIT commented 3 years ago

A solution or workaround would be really nice.

ManuelSchneid3r commented 3 years ago

I dont use this extension. So no invest from my part. Happy to merge a PR with the necessary changes though.

https://github.com/albertlauncher/python/blob/master/window_switcher/__init__.py

squalou commented 3 years ago

Hi @jason--liu I'm looking at this extension right now, and I know quite well my Python, I see what the problem may be, and probably how to work around it.

My issue is that .. in my case the plugin does not work at all ! I mean, in debug, I can see that it finds matching windows but they are never suggested in albert.

Did you have anything to do to enable it on top of ticking the checkbox in python extensions list ?

EDIT !

Window Switcher DOES work in my case, I only have one big issue : the results is hidden FAR FAR away in the list !

I wonder if there's a way to prioritize plugins results @ManuelSchneid3r ?

squalou commented 3 years ago

@jason--liu I do have a quick and dirty fix if you're interested. Note that icons are not displayed for running windows, no idea how it should be found in case of wine apps.

There is already a 'nicer' (more compact) PR here (https://github.com/albertlauncher/python/pull/126) but not perfect from my point of view (see comments there)

else you can overwrite your file :

/usr/share/albert/org.albert.extension.python/modules/window_switcher/__init__.py

with this :


# -*- coding: utf-8 -*-

"""List and manage X11 windows.

Synopsis: <filter>"""

import subprocess
from collections import namedtuple
from albert import Item, ProcAction, iconLookup

__title__ = "Window Switcher"
__version__ = "0.4.5"
__authors__ = ["Ed Perez", "manuelschneid3r", "dshoreman"]
__exec_deps__ = ["wmctrl"]

Window = namedtuple("Window", ["wid", "desktop", "wm_class", "host", "wm_name"])

def guessWin(wm_class):
    # returns win_instance and win_class based on wmtrl wm_class output taking care of weird 'wine' situations
    s = wm_class.replace(' ', '-').split('.')
    if len(s) == 4:
        # probably program.exe.program.exe
        s = [".".join([s[0], s[1]]), ".".join([s[2], s[3]])]
    return s

def handleQuery(query):
    stripped = query.string.strip().lower()
    if stripped:
        results = []
        for line in subprocess.check_output(['wmctrl', '-l', '-x']).splitlines():
            win = Window(*parseWindow(line))

            if win.desktop == "-1":
                continue

            win_instance, win_class = guessWin(win.wm_class)
            matches = [
                win_instance.lower(),
                win_class.lower(),
                win.wm_name.lower()
            ]

            if any(stripped in match for match in matches):
                iconPath = iconLookup(win_instance) or iconLookup(win_class.lower())
                results.append(Item(id="%s%s" % (__title__, win.wm_class),
                                    icon=iconPath,
                                    text="%s  - <i>Desktop %s</i>" % (win_class.replace('-',' '), win.desktop),
                                    subtext=win.wm_name,
                                    completion=win.wm_name,
                                    actions=[ProcAction("Switch Window",
                                                        ["wmctrl", '-i', '-a', win.wid] ),
                                             ProcAction("Move window to this desktop",
                                                        ["wmctrl", '-i', '-R', win.wid] ),
                                             ProcAction("Close the window gracefully.",
                                                        ["wmctrl", '-c', win.wid])]))
        return results

def parseWindow(line):
    win_id, desktop, rest = line.decode().split(None, 2)
    win_class, rest = rest.split('  ', 1)
    host, title = rest.strip().split(None, 1)

    return [win_id, desktop, win_class, host, title]
ManuelSchneid3r commented 3 years ago

please join the discussion https://github.com/albertlauncher/python/pull/126. ill lock this one. this discussion about the winswitcher is somewhat cluttered

ManuelSchneid3r commented 1 year ago

Please continue any discussion here: https://github.com/orgs/albertlauncher/discussions/1299