logo
down
shadow

Using hammerspoon and the spaces module to move window to new space


Using hammerspoon and the spaces module to move window to new space

By : Gopal
Date : November 05 2020, 03:01 PM
it helps some times After some hints from the author of the spaces module I came up with the following, which seems to do the trick.
code :
local spaces = require("hs._asm.undocumented.spaces")
-- move current window to the space sp
function MoveWindowToSpace(sp)
    local win = hs.window.focusedWindow()      -- current window
    local uuid = win:screen():spacesUUID()     -- uuid for current screen
    local spaceID = spaces.layout()[uuid][sp]  -- internal index for sp
    spaces.moveWindowToSpace(win:id(), spaceID) -- move window to new space
    spaces.changeToSpace(spaceID)              -- follow window to new space
end
hs.hotkey.bind(hyper, '1', function() MoveWindowToSpace(1) end)


Share : facebook icon twitter icon
Open window of an application and move it to a different Space in OSX, is it possible?

Open window of an application and move it to a different Space in OSX, is it possible?


By : Jkhandelwal
Date : March 29 2020, 07:55 AM
it helps some times Short answer: you can't unless you make more than one copy of the application and change its bundle identifier (not recommended for lots of reasons). Spaces works on an application basis, not a per-instance basis (which is uncommon on OS X for GUI apps anyway) nor on a per-window basis of an app.
Why does hammerspoon return focused window nil when it should not?

Why does hammerspoon return focused window nil when it should not?


By : Cau Phan
Date : March 29 2020, 07:55 AM
will help you It seemed that it might have been a incompatibility of the OS I had. Make sure to have the latest OS X and hammerspoon software.
Hammerspoon: drawing a line in the title bar of a window

Hammerspoon: drawing a line in the title bar of a window


By : F.W
Date : March 29 2020, 07:55 AM
Hope that helps As is, the code will place the bar windows width away from the left side of the screen. The seemingly fixed position is because the window width is the same. Use:
code :
hs.geometry.point(f.x + f.w, f.y)
How to move an application between monitors in Hammerspoon?

How to move an application between monitors in Hammerspoon?


By : dystopian protagonis
Date : March 29 2020, 07:55 AM
I wish did fix the issue. The screen library helps finding the right "display". allScreens lists the displays in the same order as they are defined by the system. The hs.window:moveToScreen function moves to a given screen, where it's possible to set the UUID.
The following code works for me. Hitting CTRL+ALT+CMD+ 3 moves the currently focused window to display 3, same as if you would choose "Display 3" in the Dock's Option menu.
code :
function moveWindowToDisplay(d)
  return function()
    local displays = hs.screen.allScreens()
    local win = hs.window.focusedWindow()
    win:moveToScreen(displays[d], false, true)
  end
end

hs.hotkey.bind({"ctrl", "alt", "cmd"}, "1", moveWindowToDisplay(1))
hs.hotkey.bind({"ctrl", "alt", "cmd"}, "2", moveWindowToDisplay(2))
hs.hotkey.bind({"ctrl", "alt", "cmd"}, "3", moveWindowToDisplay(3))
Lua Hammerspoon: hs.window.focusedWindow() is nil when assigned to a variable

Lua Hammerspoon: hs.window.focusedWindow() is nil when assigned to a variable


By : Mark John
Date : March 29 2020, 07:55 AM
wish of those help Hammerspoon executes each line as it's own chunk, so local variables are only available in that chunk, and no longer once the chunk has been executed.
If you want to access variables after execution of a chunk, make them global, i.e. drop the 'local' keyword.
Related Posts Related Posts :
shadow
Privacy Policy - Terms - Contact Us © voile276.org