forked from 0xl30/Hyprspace
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHyprspace.lua.bak
More file actions
183 lines (149 loc) · 5.1 KB
/
Copy pathHyprspace.lua.bak
File metadata and controls
183 lines (149 loc) · 5.1 KB
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
local M = {}
local HOME = os.getenv("HOME") or ""
local MATUGEN_PATH = HOME .. "/.config/matugen/generated/hyprland-colors.lua"
local plugin_path = os.getenv("HYPRSPACE_PLUGIN_PATH") or (HOME .. "/.config/hypr/edit_here/Hyprspace/Hyprspace.so")
local user_opts = {}
local function file_exists(path)
if type(path) ~= "string" or path == "" then
return false
end
local file = io.open(path, "r")
if not file then
return false
end
file:close()
return true
end
local function shell_quote(value)
return "'" .. tostring(value):gsub("'", "'\\''") .. "'"
end
local function load_colors(path)
local env = {}
local chunk = loadfile(path, "t", env)
if not chunk then
return {}
end
local ok = pcall(chunk)
if not ok then
return {}
end
return env
end
local function rgba_to_aarrggbb(value, fallback)
if type(fallback) ~= "number" then
return nil
end
local hex = type(value) == "string" and value:match("^rgba%((%x%x%x%x%x%x%x%x)%)$")
if not hex then
return fallback
end
local parsed = tonumber("0x" .. hex:sub(7, 8) .. hex:sub(1, 2) .. hex:sub(3, 4) .. hex:sub(5, 6))
if type(parsed) ~= "number" then
return fallback
end
return parsed
end
local function with_alpha(value, alpha, fallback)
if type(fallback) ~= "number" then
return nil
end
local base = rgba_to_aarrggbb(value, fallback)
if type(base) ~= "number" then
base = fallback
end
return ((alpha & 0xff) << 24) | (base & 0x00ffffff)
end
local function plugin_loaded()
return hl.plugin and hl.plugin.Hyprspace and type(hl.plugin.Hyprspace.overview) == "function"
end
local function ensure_plugin_loaded()
if plugin_loaded() then
return true
end
if not file_exists(plugin_path) then
return false
end
hl.exec_cmd("hyprctl plugin load " .. shell_quote(plugin_path))
return plugin_loaded()
end
local function build_config()
local colors = load_colors(MATUGEN_PATH)
local config = {
panel_color = with_alpha(colors.surface_container_high or colors.surface, 0x20, 0x20261d20),
panel_border_color = with_alpha(colors.primary or colors.outline, 0x38, 0x38ffb0cf),
workspace_active_background = with_alpha(colors.surface_container_highest or colors.surface_container_high, 0x40, 0x403c3235),
workspace_inactive_background = with_alpha(colors.surface_container or colors.surface, 0x0c, 0x0c261d20),
workspace_active_border = with_alpha(colors.primary or colors.on_surface, 0xa0, 0xa0ffb0cf),
workspace_inactive_border = with_alpha(colors.outline_variant or colors.outline, 0x15, 0x15504348),
panel_height = 220,
panel_border_width = 2,
workspace_margin = 10,
reserved_area = 35,
workspace_border_size = 3,
adaptive_height = false,
center_aligned = true,
on_bottom = false,
hide_background_layers = false,
hide_top_layers = false,
hide_overlay_layers = false,
draw_active_workspace = true,
hide_real_layers = false,
affect_strut = false,
auto_drag = true,
auto_scroll = true,
exit_on_click = true,
switch_on_drop = false,
exit_on_switch = false,
show_new_workspace = true,
show_empty_workspace = true,
show_special_workspace = false,
disable_gestures = false,
reverse_swipe = false,
swipe_fingers = 3,
swipe_distance = 300,
swipe_force_speed = 30,
swipe_cancel_ratio = 0.5,
swipe_threshold = 10.0,
swipe_closed_padding = 10.0,
workspace_scroll_speed = 2.0,
disable_blur = false,
override_anim_speed = 0.0,
drag_alpha = 0.2,
exit_key = "Escape",
click_release_threshold_ms = 200,
}
-- Merge user options
for k, v in pairs(user_opts) do
if k ~= "plugin_path" then
config[k] = v
end
end
return {
plugin = {
hyprspace = config,
},
}
end
local function apply_config()
if not plugin_loaded() then
return false
end
-- Hyprland 0.55+ native config path.
hl.config(build_config())
return true
end
function M.setup(opts)
if type(opts) == "table" then
if type(opts.plugin_path) == "string" then
plugin_path = opts.plugin_path
end
user_opts = opts
end
hl.on("hyprland.start", function()
ensure_plugin_loaded()
apply_config()
end)
ensure_plugin_loaded()
apply_config()
end
return M