-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
60 lines (52 loc) · 1.39 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
-- mod-version:3
local core = require "core"
local config = require "core.config"
local process = require "process"
config.plugins.immersive_title = {
mica = true
}
math.randomseed(os.time())
local lock = false
local last_window_title = ""
local system_set_window_title = system.set_window_title
function system.set_window_title(title)
last_window_title = title
if not lock then
system_set_window_title(title)
end
end
local function init()
local name = string.format("LITE_XL_%08x_%08x", system.get_time() // 1, math.random() * 0xFFFFFFFF // 1)
lock = true
system_set_window_title(name)
local proc = assert(process.start({
USERDIR .. "/dark_mode_monitor",
tostring(config.plugins.immersive_title.mica),
name
}, {
stdout = process.REDIRECT_PIPE,
stderr = process.REDIRECT_STDOUT,
stdin = process.REDIRECT_DISCARD,
}), "cannot start theme monitor")
core.add_thread(function()
local buf = ""
while true do
local read = proc:read_stdout()
if not read then break end
buf = buf .. read
if buf:find("found!", 1, true) then
core.log_quiet("monitoring theme changes...")
system_set_window_title(last_window_title)
lock = false
break
end
coroutine.yield()
end
end)
local core_quit = core.quit
function core.quit(force)
proc:terminate()
core_quit(force)
end
end
init()