Hammerspoon: `hs.window` method broken on 0.9.79

Created on 20 Sep 2020  路  4Comments  路  Source: Hammerspoon/hammerspoon

Calling this function will raise error after upgraded to v0.9.79.

function send_window_next_screen()
  hs.notify.show("Next Screen", "", "")
  local win = hs.window.focusedWindow()
  win:moveOneScreenEast(0)
end

Error in console:

2020-09-21 07:29:22: 07:29:22 ERROR:   LuaSkin: hs.hotkey callback: /Users/myuser/.hammerspoon/init.lua:24: attempt to call a nil value (method 'moveOneScreenEast')
stack traceback:
    /Users/myuser/.hammerspoon/init.lua:24: in function 'send_window_next_screen'
    /Users/myuser/.hammerspoon/init.lua:13: in function </Users/myuser/.hammerspoon/init.lua:13>

Most helpful comment

As a workaround, I'm using hs.grid.pushWindowNextScreen, and it's still working as of 0.9.79

function send_window_next_screen()
  hs.notify.show("Next Screen", "", "")
  local win = hs.window.focusedWindow()
  hs.grid.pushWindowNextScreen(win)
end

All 4 comments

As a workaround, I'm using hs.grid.pushWindowNextScreen, and it's still working as of 0.9.79

function send_window_next_screen()
  hs.notify.show("Next Screen", "", "")
  local win = hs.window.focusedWindow()
  hs.grid.pushWindowNextScreen(win)
end

Another possible workaround is to calculate the screen separately and then send to it: https://github.com/mirosval/dotfiles/commit/71d27175339c422153e6368af294c654bb1b93c6#diff-7f99af5084e5a4ae5d833a1c94045165

function moveWindow(where)
  if hs.window.focusedWindow() then
    local w = hs.window.frontmostWindow()
    local s = hs.screen.mainScreen()
    if (where == "east") then s = s:toEast()
    elseif (where == "west") then s = s:toWest()
    elseif (where == "south") then s = s:toSouth()
    elseif (where == "north") then s = s:toNorth()
    end
    w:moveToScreen(s)
  end
end

I was digging a bit through the code and it seems the moveOneScreen* functions are defined dynamically, so maybe that stoppped working.

See my comment in https://github.com/Hammerspoon/hammerspoon/issues/2480#issuecomment-696299482 for a potential fix. I'll try to get a pull up later when I have time to test it appropriately.

Just confirming the issue had been fixed in version 0.9.81 (5594). Thank you very much! 馃帄

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tomrbowden picture tomrbowden  路  3Comments

agzam picture agzam  路  3Comments

BigSully picture BigSully  路  3Comments

aaronjensen picture aaronjensen  路  3Comments

piskov picture piskov  路  4Comments