@@ -16,9 +16,9 @@ local uv = vim.uv or vim.loop
1616--- @return Appearance ?
1717local function parse_query_response (stdout , stderr )
1818 if M .state .system == " Linux" then
19- if stderr ~= " " then
20- return nil ;
21- end
19+ if stderr ~= " " then
20+ return nil
21+ end
2222
2323 -- https://github.com/flatpak/xdg-desktop-portal/blob/c0f0eb103effdcf3701a1bf53f12fe953fbf0b75/data/org.freedesktop.impl.portal.Settings.xml#L32-L46
2424 -- 0: no preference
7171-- The callback is called with the plaintext stdout response of the query.
7272--- @param callback ? fun ( stdout : string , stderr : string ): nil
7373--- @return nil
74- M .monitor_dark_mode = function (callback )
75- -- if no callback is provided, use a no-op
76- callback = callback or function () end
77-
78- vim .fn .jobstart (M .state .monitor_command ,
79- {
80- on_stdout = function (_ , data , _ )
81- data = table.concat (data , " " )
82-
83- if string.match (data , " uint32" ) then
84- -- check if this was a signal update with a new value,
85- -- as otherwise the fallback option will be incorrectly triggered
86- callback (data , " " )
87- end
88- end ,
89- on_stderr = function (_ , data , _ )
90- data = table.concat (data , " " )
91- callback (" " , data )
92- end
93- }
94- );
74+ M .monitor_dark_mode = function (callback )
75+ -- if no callback is provided, use a no-op
76+ callback = callback or function () end
77+
78+ vim .fn .jobstart (M .state .monitor_command , {
79+ on_stdout = function (_ , data , _ )
80+ data = table.concat (data , " " )
81+
82+ if string.match (data , " uint32" ) then
83+ -- check if this was a signal update with a new value,
84+ -- as otherwise the fallback option will be incorrectly triggered
85+ callback (data , " " )
86+ end
87+ end ,
88+ on_stderr = function (_ , data , _ )
89+ data = table.concat (data , " " )
90+ callback (" " , data )
91+ end ,
92+ })
9593end
9694
9795-- Uses a subprocess to query the system for the current dark mode setting.
@@ -178,13 +176,12 @@ M.start = function(options, state)
178176 -- act as if the timer has finished once to instantly sync on startup
179177 timer_callback ()
180178
181- -- if the system supports monitoring, prefer that over polling updates
182- if next (M .state .monitor_command ) ~= nil then
183- M .monitor_dark_mode (M .parse_callback )
184- else
185- M .start_timer ()
186- end
187-
179+ -- if the system supports monitoring, prefer that over polling updates
180+ if next (M .state .monitor_command ) ~= nil then
181+ M .monitor_dark_mode (M .parse_callback )
182+ else
183+ M .start_timer ()
184+ end
188185end
189186
190187return M
0 commit comments