asmagill / hs._asm.spaces

WIP for Hammerspoon hs.spaces module update
58 stars 3 forks source link

nil screen not found in managed displays for macOS 12.3.1 #2

Open DevinTDHa opened 2 years ago

DevinTDHa commented 2 years ago

Hi,

I am encountering some issues using the module to move windows between spaces. Running the following commands in the console results in the following errors:

> hs.spaces.allSpaces()
nil screen not found in managed displays for 37D8832A-2D66-02CA-B9F7-8F30A301B230

> hs.spaces.activeSpaceOnScreen()
nil screen not found in managed displays

> hs.spaces.activeSpaces()
nil screen not found in managed displays for 37D8832A-2D66-02CA-B9F7-8F30A301B230

Information about my system:

> hs.host.locale.preferredLanguages()

en-GB
en-DE
de-DE
vi-DE

> hs.host.locale.preferredLanguages()
en-GB
en-DE
de-DE
vi-DE

> hs.host.locale.current()
en_DE

> hs.application.applicationsForBundleID("com.apple.dock")[1]:path()
/System/Library/CoreServices/Dock.app

> hs.host.operatingSystemVersionString()
Version 12.3.1 (Build 21E258)
asmagill commented 2 years ago

I'll try and dig into this this weekend. In the mean time, when you manually go to the mission control screen (or type hs.spaces.openMissionControl() in the Hammerspoon console), how are the spaces named for your locale (for example, in the US english locale, they're named like "Desktop 1", "Desktop 2", etc. or just the sole application name if it's a full screen app.

asmagill commented 2 years ago

Oh, and I should also ask if you're using the latest Hammerspoon release? If so, these additions are now part of Hammerspoon and you don't need to use this separate module... I think they're identical (I try to keep them in sync), but just in case, you can check by doing the following to remove the independent module and use the Hammerspoon built in version:


If you built it yourself, then type make uninstall while in the source directory (preceded by PREFIX=... if you used that when installing).

If you installed one of the pre-compiled zip files, then go into your hammerspoon config directory (usually ~/.hammerspoon) and type the following:

% cd hs
% rm -fr spaces.* libspaces.*

Now fully quit and restart Hammerspoon and see if the problem persists.

DevinTDHa commented 2 years ago

Hi @asmagill,

The only things that I have modified are that the number of workspaces stays static at 4.

The names are the default ones:

image

Other than that, I am using the latest hammerspoon release and am using the included spaces library from there (not the compiled one from this repo).

MrKistic commented 2 years ago

I came here to find out about exactly this issue. What I can confirm is that this does not occur when you have selected the "Displays have separate Spaces" option in Mission Control settings. This was default option on the new Mac I'm migrating to so I didn't initially have the problem. When I disabled that option however I started getting this error.

I'm using the latest Hammerspoon version 0.9.97 (6267) and was initially using the library but have the same problem using it built in. My OS information:

> hs.host.operatingSystemVersionString()
2022-04-22 12:45:26: -- Loading extension: host
Version 12.2.1 (Build 21D62)

I've just compiled the old undocumented version for this OS and can confirm that does still work. So I can use the old version to get a space ID and can use either version to move a window to that space.

My output from hs.spaces.allSpaces():

nil screen not found in managed displays for 0908752B-5C74-4F31-ABEE-35BFFAFD5A49

My output from hs._asm.undocumented.spaces.layout():

{
  ["0908752B-5C74-4F31-ABEE-35BFFAFD5A49"] = { 1, 3, 4, 5 }
}

My spaces names are the same defaults as above so no idea why the space IDs are indexed that way but they work regardless 😄

asmagill commented 2 years ago

@DevinTDHa can you check and see if you have the "Displays have separate Spaces" option in Mission Control settings checked or unchecked? And if you have it unchecked, can you try checking it and seeing if that "fixes" it (at least while the option is checked) for you?

@MrKistic I can confirm that the axuielement data presented by the Dock does in fact differ when that item is unchecked, and the internal helper functions don't currently recognize the change to the format. I'll see about addressing that this weekend. The old module did things in an entirely different way, so that's why it seems to be unaffected.

I wouldn't be surprised if there might be other things that might not work as the module doesn't get much testing with that option unchecked. Again, I'll see about addressing that soon, but I am curious to know if there is a specific reason why you want that unchecked?

MrKistic commented 2 years ago

@asmagill Yes, I think I tested one or two other related functions that also failed but didn't record them at the time.

My preference is to set up workspaces for different projects and I like that to include all screens. Tools that I need across multiple projects/screens I use the Assign to All Desktops option in the Dock for that app. Otherwise I'll have apps & windows remain in the workspace and switch between workspaces. Just a personal preference that works better for me than Apple's ideas 😸

Thanks for the response and for looking into it. I've setup hotkeys to either switch to a workspace or move a window to a workspace and it's improved my workflows no end so thanks for your work on the libraries too. I'm okay using the older compiled library at the moment but definitely let me know if you want any further info or testing from me, I'm happy to help.

DevinTDHa commented 2 years ago

@DevinTDHa can you check and see if you have the "Displays have separate Spaces" option in Mission Control settings checked or unchecked? And if you have it unchecked, can you try checking it and seeing if that "fixes" it (at least while the option is checked) for you?

@asmagill It was indeed unchecked and checking it fixes the issue!

asmagill commented 2 years ago

An update is in progress for Hammerspoon that addresses the "Displays have separate Spaces" issue at https://github.com/Hammerspoon/hammerspoon/pull/3196. I hope to merge it in the next day or so and update the stand-alone version (here) then as well.

asmagill commented 2 years ago

Ok, I have updated the version in this repo and marked the pull request for core as ready, so let me know if you have any additional issues.