Created
April 7, 2017 09:16
-
-
Save ShiningRay/c54a638378a1c26c5e13429480504528 to your computer and use it in GitHub Desktop.
automaticly focus the frontmost window when mouse changed to another screen
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
-- hs.logger.setGlobalLogLevel('debug') | |
local logger = hs.logger.new('focus') | |
hs.timer.doEvery(3, function() | |
local current = hs.mouse.getCurrentScreen() | |
-- hs.rawprint(current) | |
if current and current ~= hs.screen.mainScreen() then | |
local windows = hs.window.orderedWindows() | |
for _, l in ipairs(windows) do | |
if l:screen() == current and l:isStandard() and l:isVisible() then | |
logger.i('mouse changed to ' .. current:name() .. ', focus ' .. l:title()) | |
l:focus() | |
break | |
end | |
end | |
end | |
end):start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment