summaryrefslogtreecommitdiff
path: root/.config/waywall/init.lua
blob: 2d6320a518fd95e2e8cd62c7e6d297cb4cacf965 (plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
local waywall = require("waywall")
local helpers = require("waywall.helpers")

local Scene = require("waywork.scene")
local Modes = require("waywork.modes")
local Keys = require("waywork.keys")
local Processes = require("waywork.processes")

local scene = Scene.SceneManager.new(waywall)
local ModeManager = Modes.ModeManager.new(waywall)

local waywall_config_path = os.getenv("HOME") .. "/.config/waywall"

--[[
celeste menu colors:

light pink: ff92b1
lavender: 9768e4
med green: 419462
pale yellow: ffff99
gray blue: 759cb2
dark gray blue: 36527c
dark gray: 3b566b
cyan: 53cfde
brick red: ba5358
med yellow: fff672
royal purple: 8d24ed
pale pink: eb82ff
sky blue: 54b0ff
cornflower blue: 606de7
gold: ffea42
med blue: 448ede
deep red: 8a2939
brightish red: f53c4c

--]]

local bg_color = "#ffffff"

local pie_colors = {
	entities        = { pie = "#e446c4", text = "#e145c2", out = "#f225fc" },
	unspecified     = { pie = "#46ce66", text = "#45cc65", out = "#56f440" },
	blockEntities   = { pie = "#ec6e4e", text = "#e96d4d", out = "#f48769" },
	destroyProgress = { pie = "#cc6c46", text = "#ca6b45", out = "#c78b56" },
	mob_spawner     = { pie = "#4ee4cc", text = "#4de1ca", out = "#63f9fb" },
	chest           = { pie = "#c66ee4", text = "#c46de1", out = "#e75dfc" },
}

local normal_sens = 12.800000599064097
local tall_sens = 0.8634803836976988

local pie_dst     = { x = 1200, y = 400, w = 340,    h = 340 }
local percent_dst = { x = 1280, y = 800, w = 34 * 6, h = 25 * 6 }
local eye_dst     = { x =   30, y = 340, w = 700,    h = 400 }

local f3_root = { x = 1200, y = 150 }
local f3_scale = 5
local f3_text_color = "#48106e"

function add_f3_scene(name, row, col, len, groups)
	scene:register(name, {
		kind = "mirror",
		options = {
			src = { x = col * 6 + 1, y = row * 9 + 1, w = len * 6, h = 9 },
			dst = { x = f3_root.x, y = f3_root.y, w = len * 6 * f3_scale, h = 9 * f3_scale },
			color_key = {
				input = "#dddddd",
				output = f3_text_color,
			},
			depth = 1,
		},
		groups = groups,
	})
	f3_root.y = f3_root.y + 9 * f3_scale
end

add_f3_scene("c_counter", 3, 0, 11, { "thin", "tall" })
add_f3_scene("e_counter", 4, 0, 8, { "thin", "tall" })

for _, name in ipairs({ "wide", "thin", "tall" }) do
	scene:register(name .. "_bg", {
		kind = "image",
		path = waywall_config_path .. "/resources/" .. name .. "_bg.png",
		options = {
			dst = { x = 0, y = 0, w = 1920, h = 1080 },
		},
		groups = { name },
	})
end

scene:register("bubble", {
	kind = "image",
	path = waywall_config_path .. "/resources/bubble_pie.png",
	options = {
		dst = pie_dst,
		depth = -1
	},
	groups = { "thin", "tall" },
})

for name, colors in pairs(pie_colors) do
	scene:register("thin_pie_" .. name, {
		kind = "mirror",
		options = {
			src = { x = 9, y = 680, w = 321, h = 160 },
			dst = pie_dst,
			color_key = { input = colors.pie, output = colors.out },
		},
		groups = { "thin" },
	})

	scene:register("tall_pie_" .. name, {
		kind = "mirror",
		options = {
			src = { x = 9, y = 15984, w = 321, h = 160 },
			dst = pie_dst,
			color_key = { input = colors.pie, output = colors.out },
		},
		groups = { "tall" },
	})
	scene:register("thin_percent_" .. name, {
		kind = "mirror",
		options = {
			src = { x = 247, y = 859, w = 34, h = 25 },
			dst = percent_dst,
			color_key = { input = colors.text, output = colors.out },
			depth = 1,
		},
		groups = { "thin" },
	})
	scene:register("tall_percent_" .. name, {
		kind = "mirror",
		options = {
			src = { x = 247, y = 16163, w = 34, h = 25 },
			dst = percent_dst,
			color_key = { input = colors.text, output = colors.out },
			depth = 1,
		},
		groups = { "tall" },
	})
end

scene:register("eye_measure", {
	kind = "mirror",
	options = {
		src = { x = 140, y = 7902, w = 60, h = 580 },
		dst = eye_dst,
	},
	groups = { "tall" },
})

scene:register("eye_overlay", {
	kind = "image",
	path = waywall_config_path .. "/resources/measuring_overlay.png",
	options = { dst = eye_dst },
	groups = { "tall" },
})

ModeManager:define("thin", {
	width = 340,
	height = 1080,
	on_enter = function() scene:enable_group("thin", true) end,
	on_exit = function() scene:enable_group("thin", false) end,
})

ModeManager:define("tall", {
	width = 340,
	height = 16384,
	on_enter = function()
		scene:enable_group("tall", true)
		waywall.set_sensitivity(tall_sens)
	end,
	on_exit = function()
		scene:enable_group("tall", false)
		waywall.set_sensitivity(normal_sens)
	end,
})

ModeManager:define("wide", {
	width = 1920,
	height = 300,
	on_enter = function() scene:enable_group("wide", true) end,
	on_exit = function() scene:enable_group("wide", false) end,
})

local ninbot_path = waywall_config_path .. "/result/bin/ninjabrain-bot"
local ensure_ninbot = Processes.ensure_application(waywall, ninbot_path)("[Nn]injabrain.*\\.jar")

function prevent_double_maps(remaps)
	for k, v in pairs(remaps) do
		remaps[v] = k
	end
	return remaps
end

return {
	input = {
		layout = "us",
		variant = "colemak_dh",
		repeat_rate = 40,
		repeat_delay = 300,
		sensitivity = normal_sens,
		confine_pointer = false,
		remaps = prevent_double_maps({
			["MB5"] = "F3",
			["Enter"] = "Esc",
			["dot"] = "leftctrl",
			["slash"] = "rightshift",
			["MB4"] = "leftshift",
		}),
	},
	theme = {
		background = bg_color,
		ninb_anchor = "bottomright",
		ninb_opacity = 1.0,
	},
	experimental = {
		debug = false,
		jit = false,
		tearing = false,
		scene_add_text = true,
	},
	actions = Keys.actions({
		["*-bracketleft"] = function() return ModeManager:toggle("thin") end,
		["*-bracketright"] = function() return ModeManager:toggle("tall") end,
		["*-apostrophe"] = function() return ModeManager:toggle("wide") end,
		["*-Alt_L"] = function()
			ensure_ninbot()
			helpers.toggle_floating()
		end,
	}),
}