Kalmat / PyWinCtl

Cross-Platform module to get info on and control windows on screen
Other
179 stars 19 forks source link

Get active window title does not work on xmonad #64

Closed user202729 closed 1 year ago

user202729 commented 1 year ago

As in the title.

I think I know how and figure out an alternative working solution, refer to https://stackoverflow.com/a/76394437/5267751. But it still seems a bit fickle.

Kalmat commented 1 year ago

Hi! Thank you for your help! I didn't know about xmonad at all (just curious, what advantages it has versus other window managers?).

pyewmh and pywinctl rely on EWMH specs ("_NET_ACTIVE_WINDOW", in this case). Making a quick search, I have found that EWMH must be explicitly enabled in xmonad (see here). Perhaps this can fix the issue... but not sure if this is acceptable for some or all xmonad users.

I will test your solution to check if it works in all cases and other methods (thank you!!!) Perhaps it can also work with Wayland, in which I recently discovered that retrieving the active window or any window title is not working either.

user202729 commented 1 year ago

It's a tiling window manager (homepage https://xmonad.org/). (anecdote, some people find xmonad a bit too difficult to configure and use i3 instead)

As xdotool documentation states, getactivewindow is more reliable than getwindowfocus so maybe only use the latter if the former is unavailable.

As for Wayland, I don't use it so don't have experience but as the library is named Xlib I think it probably won't work either. There's the pywayland library, maybe it will be useful for something. [edit: looks a bit more difficult I can find https://askubuntu.com/questions/1414320/how-to-get-current-active-window-in-ubuntu-22-04 https://unix.stackexchange.com/questions/399753/how-to-get-a-list-of-active-windows-when-using-wayland ]


Yes I should have figured that one out earlier. I change xmobar def {...} in my config with xmobar (ewmh def {...}) and add import XMonad.Hooks.EwmhDesktops, and pywinctl works without any change. Similarly xdotool getactivewindow also works now. {later edit: enabling ewmh has the side effect of making zathura --synctex-forward switch focus to the zathura window, will figure out later}

Kalmat commented 1 year ago

Hi! Sorry for my late reply, but I was completely unable to install xmonad in my (actual, not VM) Ubuntu installation. I already read about activating ewmh in Xmonad (also because we are working in a pyewmh module replacement). In fact, that was my first option, but I never could confirm... Thank you so much for your feedback!!!! I do really appreciate it.