BurntSushi / xpybutil

An incomplete xcb-util port plus some extras
Do What The F*ck You Want To Public License
62 stars 15 forks source link

ewmh.get_desktop_names() gets out of sync with actual desktop manager #17

Open tauchris opened 1 year ago

tauchris commented 1 year ago

While tinkering with a script to rename and select virtual desktops from a Python script, using xpybutil, I ran into a scenario in which my desktop manager had 8 virtual desktops, but ewhm.get_desktop_names() seemed to be returning some old/cached value from a good while back (probably more than an hour old). Other ewmh APIS seem to be working correctly (giving current/accurate results). Not sure if this is a bug in the ewhm module of xpybutil, or something deeper (something buggy in the Mate desktop manager?) -- but the Workspace Switcher Preferences dialog for the panel applet appears to be correct/accurate, and works correctly, which seems to suggest that the bug is not in the desktop manager... (?) Here's my sample script (as testgetnames.txt -- ironic that it's not possible to attach a python script as "*.py" here...) and a screen shot of the results, showing the bug.

testgetnames.txt Capture

Note, I'm using Python 3.11.0 on x86_64 GNU/Linux, and Mate Desktop Environment 1.16.2.

BurntSushi commented 1 year ago

I stopped using this package probably more than 10 years ago. Sorry, but I don't know how to help you.

I think you should use tools like xprop to confirm whether your environment is conforming to EWMH or not.

tauchris commented 1 year ago

Thanks for the answer!

Dug into spec a bit -- seems there is no reliable relationship between what _NET_DESKTOP_NAMES can return and what the actual visible desktops are. From the spec (https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm45154644308928):

_NET_DESKTOP_NAMES

_NET_DESKTOP_NAMES, UTF8_STRING[]

The names of all virtual desktops. This is a list of NULL-terminated strings in UTF-8 encoding [UTF8]. This
property MAY be changed by a Pager or the Window Manager at any time.

Note: The number of names could be different from _NET_NUMBER_OF_DESKTOPS. If it is less than
_NET_NUMBER_OF_DESKTOPS, then the desktops with high numbers are unnamed. If it is larger than
_NET_NUMBER_OF_DESKTOPS, then the excess names outside of the _NET_NUMBER_OF_DESKTOPS are
considered to be reserved in case the number of desktops is increased.

Rationale: The name is not a necessary attribute of a virtual desktop. Thus the availability or unavailability
of names has no impact on virtual desktop functionality. Since names are set by users and users are likely
to preset names for a fixed number of desktops, it doesn't make sense to shrink or grow this list when the
number of available desktops changes.

So, that begs the question of whether there is value in using this API to programmatically access/manipulate virtual desktops... Pretty disappointing, but certainly, can't blame this library for EWMH's shortcomings, if I'm understanding that correctly.