aboutsummaryrefslogtreecommitdiffstats
path: root/window_layout.lua
diff options
context:
space:
mode:
authorTeddy Wing2019-07-26 22:07:38 +0200
committerTeddy Wing2019-07-26 22:07:38 +0200
commite826cb04b8d827275a81cc8371e5217ca8a2fb4f (patch)
treebac07d57e703433288b62b1bfe8329bb51f358fa /window_layout.lua
parent08d0aab5a7a82f29150910979552928025cfc630 (diff)
downloaddothammerspoon-e826cb04b8d827275a81cc8371e5217ca8a2fb4f.tar.bz2
window_layout: Fix iTerm window #2 targeting
Using an index of 2 didn't guarantee that the window accessed would be window #2. Turns out the order of windows in the list is not consistent. In order to target window #2, look for the "2. " prefix in the window title.
Diffstat (limited to 'window_layout.lua')
-rw-r--r--window_layout.lua10
1 files changed, 6 insertions, 4 deletions
diff --git a/window_layout.lua b/window_layout.lua
index 1b6a8b1..263bc89 100644
--- a/window_layout.lua
+++ b/window_layout.lua
@@ -2,10 +2,12 @@
-- https://www.hammerspoon.org/docs/hs.screen.watcher.html
-- hs.screen.primaryScreen():name() == 'G247HL'
local function iterm2()
- -- TODO: Use `filter()` to get windows with title starting with "2. ". This
- -- code grabbed window 3 once.
- local win_2 = hs.application.find('com.googlecode.iterm2'):allWindows()[2]
- win_2:setFrame(hs.geometry.rect(-1253.0,23.0,793.0,873.0))
+ for _, window in ipairs(hs.application.find('com.googlecode.iterm2'):allWindows()) do
+ if window:title():match('^2%. ') then
+ window:setFrame(hs.geometry.rect(-1253.0,23.0,793.0,873.0))
+ return
+ end
+ end
end