Skip to content

Commit c439798

Browse files
committed
refactor: use table for monitor command
1 parent 9c18031 commit c439798

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lua/auto-dark-mode/init.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ M.state = {
5454
system = nil,
5555
---@type table
5656
query_command = {},
57-
---@type string?
58-
monitor_command = nil,
57+
---@type table
58+
monitor_command = {},
5959
}
6060

6161
---@return nil
@@ -96,7 +96,12 @@ M.init = function()
9696
}
9797

9898
if vim.fn.executable("dbus-monitor") ~= 0 then
99-
M.state.monitor_command = "dbus-monitor --session type=signal,interface=org.freedesktop.portal.Settings,member=SettingChanged,path=/org/freedesktop/portal/desktop,arg0='org.freedesktop.appearance',arg1='color-scheme'"
99+
M.state.monitor_command = {
100+
"dbus-monitor",
101+
"--session",
102+
"type=signal,interface=org.freedesktop.portal.Settings,member=SettingChanged,path=/org/freedesktop/portal/desktop,arg0='org.freedesktop.appearance',arg1='color-scheme'",
103+
}
104+
100105
end
101106
elseif M.state.system == "Windows_NT" or M.state.system == "WSL" then
102107
local reg = "reg.exe"

lua/auto-dark-mode/interval.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ M.start = function(options, state)
179179
timer_callback()
180180

181181
-- if the system supports monitoring, prefer that over polling updates
182-
if M.state.monitor_command then
182+
if next(M.state.monitor_command) ~= nil then
183183
M.monitor_dark_mode(M.parse_callback)
184184
else
185185
M.start_timer()

0 commit comments

Comments
 (0)