-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppBorders.lua
93 lines (76 loc) · 2.58 KB
/
AppBorders.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
--- Generated by Luanalysis
--- Created by muescha.
--- DateTime: 05.08.22 13:13
---
--- based on https://github.com/jwkvam/hammerspoon-config/blob/master/init.lua#L183
fileInfo()
-- see check for some apps
-- https://github.com/folke/dot/blob/master/hammerspoon/border.lua
-- https://github.com/folke/dot/blob/master/hammerspoon/running.lua --> many foo maguc
local logger = hs.logger.new("AppBorders")
logger.i("Init")
local global_border = nil
function initBorder()
win = hs.window.focusedWindow()
if win ~= nil then
frame = hs.window.focusedWindow():frame()
else
frame = hs.geometry.new(0, 0, 0, 0)
end
global_border = hs.drawing.rectangle(frame)
global_border:setStrokeColor({ ["red"] = 1, ["blue"] = 0, ["green"] = 0, ["alpha"] = 0.8 })
global_border:setFill(false)
global_border:setStrokeWidth(8)
global_border:show()
--debugInfo("---------")
--debugInfo("Draw")
--debugInfo("---------")
end
function redrawBorder(window, name, event)
--debugInfo("- - - - - - - - -")
--debugInfo(name)
--debugInfo(event)
--debugInfo("- - - - - - - - -")
-- TODO -> change to parameter and as table
if name == 'Kontrollzentrum' then return end
win = hs.window.focusedWindow()
if win ~= nil then
newFrame = win:frame()
currentFrame = global_border:frame()
if not newFrame:equals(currentFrame) then
--debugInfo("---------")
--debugInfo("redraw")
--debugInfo("---------")
global_border:setFrame(newFrame)
end
global_border:show()
else
global_border:hide()
end
end
initBorder()
allwindows = hs.window.filter.new(nil)
allwindows:subscribe(hs.window.filter.windowCreated, redrawBorder)
allwindows:subscribe(hs.window.filter.windowDestroyed, redrawBorder)
allwindows:subscribe(hs.window.filter.windowFocused, redrawBorder)
allwindows:subscribe(hs.window.filter.windowMoved, redrawBorder)
allwindows:subscribe(hs.window.filter.windowUnfocused, redrawBorder)
function debugEvents(window, name, event)
win = hs.window.focusedWindow()
debugInfo("=========")
debugInfo(win)
debugInfo(win and win:title())
debugInfo(win and win:role())
debugInfo(win and win:subrole())
debugInfo(win and win:pid())
debugInfo("---------")
debugInfo(window)
debugInfo(window and window:title())
debugInfo(window and window:role())
debugInfo(window and window:subrole())
debugInfo(window and window:pid())
debugInfo(name)
debugInfo(event)
end
--allwindows:subscribe(hs.window.filter.events, debugEvents)