-
Notifications
You must be signed in to change notification settings - Fork 0
/
MultiDisplayBlack.lua
87 lines (70 loc) · 1.97 KB
/
MultiDisplayBlack.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
---
--- Generated by Luanalysis
--- Created by muescha.
--- DateTime: 18.12.22 07:40
--- source: https://github.com/JJGO/dotfiles/blob/master/mac/.hammerspoon/multidisplay-black.lua
-- Hyper+F11 toggles black boxes on secondary monitors
fileInfo()
movieblocks = nil
local function blackOff()
if movieblocks == nil then return end
for k, v in pairs(movieblocks) do
v:delete()
end
movieblocks = nil
end
function blackOn(all)
p = hs.screen.primaryScreen()
movieblocks = {}
for k, v in pairs(hs.screen.allScreens()) do
if v:name() ~= p:name() or all == true then
max = v:fullFrame()
box = hs.drawing.rectangle(hs.geometry.rect(max.x, max.y, max.w, max.h))
black = {["red"]=0,["blue"]=0,["green"]=0,["alpha"]=1.0}
box:setStrokeColor(black)
box:setFillColor(black)
box:setFill(true)
box:show()
-- v:setBrightness(0.0)
movieblocks[k] = box
end
end
end
function toggleMovieMode(all)
if movieblocks ~= nil then
blackOff()
for k, v in pairs(hs.screen.allScreens()) do
v:setBrightness(0.3)
end
else
blackOn(all)
for k, v in pairs(hs.screen.allScreens()) do
v:setBrightness(1)
end
end
end
function blackOnAll()
blackOn(true)
end
function toggleMovieModeAll()
toggleMovieMode(true)
end
--hs.hotkey.bind(hyper, "2", keyInfo("toggle other display black"),toggleMovieMode)
--hs.hotkey.bind(hyper, "3", keyInfo("toggle all display black"),toggleMovieModeAll)
local modalGroup = {}
hotkeybindmodalgroup(
hyper,
"5",
keyInfo("toggle other display black"),
function() blackOn() end,
function() blackOff() end,
modalGroup
);
hotkeybindmodalgroup(
hyper,
"6",
keyInfo("toggle all displays black"),
function() blackOnAll() end,
function() blackOff() end,
modalGroup
);