neovim: fix wsl constant
30546269b65235ce41e1569e76467f10d0a2c3a2
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
- Parent 1: 288aa634bb27
bugabingas dorkfiles
30546269b65235ce41e1569e76467f10d0a2c3a2
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
+36 / −32 text lines
+1 / −1 text lines
+35 / −31 text lines
return { win32 = vim.loop.os_uname().sysname:match 'Win', wsl2 = vim.loop.os_uname().release:match 'WSL2', os_background = (function () -- Default value local background = 'light' local uname = vim.uv.os_uname() -- First check whether we are on WSL or Windows if vim.loop.os_uname().release:match 'WSL2' then -- Check if 'reg.exe' is executable if vim.fn.executable 'reg.exe' ~= 0 then -- Execute command to check if the win32 appearance is set to Dark local appsUseLightTheme = vim.fn.system { 'reg.exe', 'Query', 'HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize', '/v', 'AppsUseLightTheme' } if not appsUseLightTheme:find '0x1' then background = 'dark' end end -- Check if 'busctl' is executable (part of systemd) elseif vim.fn.executable 'busctl' ~= 0 then -- Get the current color scheme from xdg-desktop-portal using busctl local result = vim.fn.system { 'busctl', '--user', 'call', 'org.freedesktop.portal.Desktop', '/org/freedesktop/portal/desktop', 'org.freedesktop.portal.Settings', 'ReadOne', 'ss', 'org.freedesktop.appearance', 'color-scheme', } -- The result is in the form of "v u 0" for light and "v u 1" for dark local color_scheme = result:match 'u%s+(%d+)' if color_scheme == '1' thenlocal os_background = function () -- Default value local background = 'light' -- First check whether we are on WSL or Windows if win32 or wsl then -- Check if 'reg.exe' is executable if vim.fn.executable 'reg.exe' ~= 0 then -- Execute command to check if the win32 appearance is set to Dark local appsUseLightTheme = vim.fn.system { 'reg.exe', 'Query', 'HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize', '/v', 'AppsUseLightTheme' } if not appsUseLightTheme:find '0x1' then else -- Check if 'busctl' is executable (part of systemd) elseif vim.fn.executable 'busctl' ~= 0 then -- Get the current color scheme from xdg-desktop-portal using busctl local result = vim.fn.system { 'busctl', '--user', 'call', 'org.freedesktop.portal.Desktop', '/org/freedesktop/portal/desktop', 'org.freedesktop.portal.Settings', 'ReadOne', 'ss', 'org.freedesktop.appearance', 'color-scheme', } -- The result is in the form of "v u 0" for light and "v u 1" for dark local color_scheme = result:match 'u%s+(%d+)'