Last active
April 12, 2021 12:51
-
-
Save tamastimar/3fc39cf983ad3187ed2e to your computer and use it in GitHub Desktop.
Hammerspoon (http://hammerspoon.org) script to switch to next window of frontmost app in OS X
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Window Manipulation | |
-- Bind alt-Tab to show next window of current application | |
hs.hotkey.bind({"alt"}, "Tab", function() | |
local app = hs.application.frontmostApplication() | |
local windows = app:allWindows() | |
local nextWin = nil | |
-- Finder somehow has one more invisible window, so don't take it into account | |
-- (only tested on Yosemite 10.10.1) | |
if app:bundleID() == "com.apple.finder" then | |
nextWin = windows[#windows-1] | |
else | |
nextWin = windows[#windows] | |
end | |
if nextWin:isMinimized() == true then | |
nextWin:unminimize() | |
else | |
nextWin:focus() | |
end | |
end) |
Thanks for the comment!
Even if that's the case unfortunately it doesn't respond to the focus() call. (Maybe that's how the desktop should work.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I haven't checked to be sure, but I am tempted to guess that Finder's weird invisible window might well be the desktop