-
Notifications
You must be signed in to change notification settings - Fork 0
/
open.lua
36 lines (31 loc) · 993 Bytes
/
open.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local screens = require("screens")
function open(app)
focused = hs.application.launchOrFocus(app)
if app == "Code" and not focused then
-- special logic for code
-- https://github.com/Hammerspoon/hammerspoon/issues/2075
focused = hs.application.launchOrFocus("Visual Studio Code")
end
return focused
end
function openAndMove(app, screen, t_ratio, l_ratio, h_ratio, w_ratio)
focused = open(app)
if not focused then return false end
window = hs.window.focusedWindow()
screens.placeWindow(window, screen, t_ratio, l_ratio, h_ratio, w_ratio)
return true
end
function openFullscreen(app, screen)
focused = open(app)
if not focused then return false end
window = hs.window.focusedWindow()
-- window:setFullScreen(false)
window:moveToScreen(screens.SCREENS[screen])
window:setFullScreen(true)
return true
end
local o = {}
o.open = open
o.openAndMove = openAndMove
o.openFullscreen = openFullscreen
return o