Skip to content
This repository was archived by the owner on Mar 12, 2022. It is now read-only.

Commit ce77eab

Browse files
committed
add layout function
1 parent 4e9f46f commit ce77eab

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

Diff for: README.md

+30-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@ I make no promises that these will work for you or work at all with any, past, c
99

1010
### Installation
1111

12-
An early release version of just this module is included in the repository as the file `spaces.tar.gz` file in the spaces subdirectory. You can install it by downloading the file and expanding it in your `~/.hammerspoon/` directory with `tar -xzf spaces.tar.gz`.
12+
Compiled versions of this module can be found in the releases. You can download the release and install it by expanding it in your `~/.hammerspoon/` directory (or any other directory in your `package.path` and `package.cpath` search paths):
13+
14+
~~~sh
15+
cd ~/.hammerspoon
16+
tar -xzf ~/Downloads/spaces-vX.Y.tar.gz # or wherever your downloads are saved
17+
~~~
1318

1419
If this doesn't work for you, or you want to build the latest and greatest, follow the directions below:
1520

1621
This does require that you have XCode or the XCode Command Line Tools installed. See the App Store application or https://developer.apple.com to install these if necessary.
1722

18-
~~~bash
23+
~~~sh
1924
$ git clone https://github.com/asmagill/hs._asm.undocumented.spaces spaces
2025
$ cd spaces
2126
$ [HS_APPLICATION=/Applications] [PREFIX=~/.hammerspoon] make install
@@ -31,6 +36,8 @@ In either case, if you are upgrading over a previous installation of this module
3136
spaces = require("hs._asm.undocumented.spaces")
3237
~~~
3338

39+
- - -
40+
3441
### Module Functions
3542

3643
~~~lua
@@ -118,6 +125,21 @@ Notes:
118125

119126
- - -
120127

128+
~~~lua
129+
spaces.layout() -> table
130+
~~~
131+
Returns a table of the user accessible spaces for, separated by Screen (Display), in order.
132+
133+
Parameters:
134+
* None
135+
136+
Returns:
137+
* a table whose keys are the screenUUID of the available screens. Each key's value is an array of the spaces on that display, list in the order in which they are currently arranged.
138+
139+
Notes:
140+
* to determine which spaces are currently visible on each screen, use `hs._asm.undocumented.spaces.query(hs._asm.undocumented.spaces.masks.currentSpaces)`.
141+
- - -
142+
121143
~~~lua
122144
spaces.mainScreenUUID() -> UUIDString
123145
~~~
@@ -288,6 +310,8 @@ Notes:
288310

289311
### Module Constants
290312

313+
- - -
314+
291315
~~~lua
292316
spaces.masks
293317
~~~
@@ -353,6 +377,8 @@ hs.window:spacesMoveTo(spaceID) -> windowObject
353377
~~~
354378
A Convienence method using `hs._asm.spaces.moveWindowToSpace` added to the `hs.window` object metatable to move the window specified by the `hs.window` object to the specified space.
355379

380+
* * *
381+
356382
### Sub-Modules
357383

358384
#### `spaces.debug`
@@ -361,6 +387,8 @@ This sub module contains functions which report a lot of detail about the spaces
361387

362388
If you do submit an issue to this repository, I may ask for information provided by one or more of these functions. Feel free to review the output and replace anything you think might be sensitive such as file paths or usernames with something like `*********`.
363389

390+
- - -
391+
364392
~~~lua
365393
spaces.debug.layout() -> string
366394
~~~

Diff for: init.lua

+11
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,17 @@ module.moveWindowToSpace = function(...)
411411
end
412412
end
413413

414+
module.layout = function()
415+
local results = {}
416+
for i,v in ipairs(internal.details()) do
417+
results[v["Display Identifier"]] = {}
418+
for j,k in ipairs(v.Spaces) do
419+
table.insert(results[v["Display Identifier"]], k.ManagedSpaceID)
420+
end
421+
end
422+
return results
423+
end
424+
414425
module.query = function(...)
415426
local args = table.pack(...)
416427
if args.n <= 2 then

Diff for: spaces.tar.gz

-25.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)