forked from linuxmobile/astal-bar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
104 lines (90 loc) · 2.53 KB
/
init.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
94
95
96
97
98
99
100
101
102
103
104
local astal = require("astal")
local App = require("astal.gtk3.app")
local Debug = require("lua.lib.debug")
Debug.info("App", "Starting astal-bar")
Debug.info("App", "Modules loaded successfully")
local Desktop = require("lua.windows.Desktop")
local Bar = require("lua.windows.Bar")
local Dock = require("lua.windows.Dock")
local NotificationPopups = require("lua.windows.NotificationPopups")
local OSD = require("lua.windows.OSD")
local src = require("lua.lib.common").src
Debug.info("App", "Components loaded successfully")
Debug.set_config({
log_to_file = true,
log_to_console = false,
max_file_size = 1024 * 1024,
log_level = Debug.LEVELS.DEBUG,
})
local scss = src("scss/style.scss")
local css = "/tmp/style.css"
astal.exec("sass " .. scss .. " " .. css)
local user_vars = loadfile(src("user-variables.lua"))()
local monitor_config = user_vars.monitor or {
mode = "primary",
specific_monitor = 1,
}
App:start({
instance_name = "kaneru",
css = css,
on_second_instance = function()
Debug.warn("App", "Another instance attempted to start")
end,
request_handler = function(msg, res)
Debug.debug("App", "Request received: %s", msg)
res("ok")
end,
main = function()
if #App.monitors == 0 then
Debug.error("App", "No monitors detected")
return
end
local function get_target_monitor()
if monitor_config.mode == "specific" then
local monitor = App.monitors[monitor_config.specific_monitor]
if not monitor then
Debug.warn("App", "Specified monitor not found, falling back to primary")
return App.monitors[1]
end
return monitor
else
return App.monitors[1]
end
end
local function create_windows(monitor)
if not monitor then
Debug.error("App", "Invalid monitor provided")
return false
end
local windows = {
-- desktop = Desktop(monitor),
bar = Bar(monitor),
dock = Dock(monitor),
notifications = NotificationPopups(monitor),
osd = OSD(monitor),
}
for name, window in pairs(windows) do
if not window then
Debug.error("App", "Failed to create " .. name)
return false
end
window.gdkmonitor = monitor
end
return true
end
if monitor_config.mode == "all" then
for _, monitor in ipairs(App.monitors) do
if not create_windows(monitor) then
Debug.error("App", "Failed to create windows for monitor")
return
end
end
else
local target_monitor = get_target_monitor()
if not create_windows(target_monitor) then
Debug.error("App", "Failed to create windows for target monitor")
return
end
end
end,
})