aboutsummaryrefslogtreecommitdiffstats
path: root/window_layout.lua
diff options
context:
space:
mode:
authorTeddy Wing2019-07-25 00:18:36 +0200
committerTeddy Wing2019-07-25 00:18:36 +0200
commit08d0aab5a7a82f29150910979552928025cfc630 (patch)
treefb7c54c2338c5b63b35e9708524548d0b80468b5 /window_layout.lua
parentbb85b4795b5d3cd07c62c26b6040ab2935f313d8 (diff)
downloaddothammerspoon-08d0aab5a7a82f29150910979552928025cfc630.tar.bz2
Automatically reposition iTerm window 2 when external monitor connected
When my external monitor is connected, ensure that iTerm's window #2 is in the proper position. iTerm has a habit of getting its window layout screwed up when switching monitors (or just not remembering window layouts between monitors).
Diffstat (limited to 'window_layout.lua')
-rw-r--r--window_layout.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/window_layout.lua b/window_layout.lua
new file mode 100644
index 0000000..1b6a8b1
--- /dev/null
+++ b/window_layout.lua
@@ -0,0 +1,17 @@
+-- Do this when external monitor is connected
+-- 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))
+end
+
+
+screen_watcher = hs.screen.watcher.new(function()
+ if hs.screen.primaryScreen():name() == 'G247HL' then
+ iterm2()
+ end
+end)
+screen_watcher:start()