Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hs.spaces.watcher will never provide a non -1 space id. #3250

Open
JDKardia opened this issue Jul 6, 2022 · 1 comment
Open

hs.spaces.watcher will never provide a non -1 space id. #3250

JDKardia opened this issue Jul 6, 2022 · 1 comment

Comments

@JDKardia
Copy link

JDKardia commented Jul 6, 2022

The gist is hs.spaces.watcher will never provide me with a proper space id.

example run via hs.ipc within the hs repl

> w = hs.spaces.watcher.new(function(s) print("changed to space " .. s) end)

> w.start(w)
hs.spaces.watcher: (0x6000019bc628)

> changed to space -1
changed to space -1
changed to space -1
changed to space -1

However, hs.spaces is clearly not clueless:

> hs.spaces.allSpaces()
{
  ["UUID-1"] = { 1, 3, 4, 5 },
  ["UUID-2"] = { 1153, 891, 919, 429, 435, 802, 62, 803 }
}

> hs.spaces.activeSpaces()
{
  ["UUID-1"] = 1,
  ["UUID-2"] = 919
}

> hs.spaces.focusedSpace()
919

Possibly Relevant System Info:

Model Name              : MacBook Pro
Model Identifier        : MacBookPro18,1
Chip                    : Apple M1 Pro
Total Number of Cores   : 10 (8 performance and 2 efficiency)
Memory                  : 16 GB
System Firmware Version : 7459.121.3
OS Loader Version       : 7459.121.3
System Version          : macOS 12.4 (21F79)
Kernel Version          : Darwin 21.5.0

P.S. Are my workspace numbers normal? I feel like they're a bit... high.

@dasmurphy
Copy link

The numbers are looking fine to me. Mine are also high values. I think they are random... As far as i remember there was a problem with checking for the current space...

The docs here also state ...(or -1 if the number cannot be determined). So you may use hs.spaces.focusedSpace() to get the number of the space. Hope this helps. Your indication that -1 is not the best value is correct.

w = hs.spaces.watcher.new(function(s)
  print("changed to space "..hs.spaces.focusedSpace())
end)
ww = w.start()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants