@@ -75,21 +75,39 @@ M.monitor_dark_mode = function(callback)
7575 -- if no callback is provided, use a no-op
7676 callback = callback or function () end
7777
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- })
78+ if vim .system then
79+ vim .system (M .state .monitor_command , {
80+ text = true ,
81+ stdout = function (_ , data )
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+ stderr = function (_ , data )
89+ callback (" " , data )
90+ end ,
91+ })
92+ else
93+ -- Legacy implementation using `vim.fn.jobstart` instead of `vim.system`,
94+ -- for use in neovim <0.10.0
95+ vim .fn .jobstart (M .state .monitor_command , {
96+ on_stdout = function (_ , data , _ )
97+ data = table.concat (data , " " )
98+
99+ if string.match (data , " uint32" ) then
100+ -- check if this was a signal update with a new value,
101+ -- as otherwise the fallback option will be incorrectly triggered
102+ callback (data , " " )
103+ end
104+ end ,
105+ on_stderr = function (_ , data , _ )
106+ data = table.concat (data , " " )
107+ callback (" " , data )
108+ end ,
109+ })
110+ end
93111end
94112
95113-- Uses a subprocess to query the system for the current dark mode setting.
0 commit comments