This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools.nvim: fix theme tracking on nixos

+35 -29
+35 -29
tools/nvim/flake-module.nix
··· 40 40 is_dark = result:match("Dark") ~= nil 41 41 elseif vim.fn.has("unix") == 1 then 42 42 -- Linux: check if running under a dark theme 43 - -- Try multiple methods to detect dark theme 44 - local methods = { 45 - -- GNOME/GTK 46 - "gsettings get org.gnome.desktop.interface gtk-theme 2>/dev/null", 47 - "gsettings get org.gnome.desktop.interface color-scheme 2>/dev/null", 48 - -- KDE 49 - "kreadconfig5 --file kdeglobals --group General --key ColorScheme 2>/dev/null", 50 - -- Check if COLORFGBG suggests dark background 51 - function() 52 - local colorfgbg = vim.env.COLORFGBG 53 - if colorfgbg then 54 - local fg, bg = colorfgbg:match("(%d+);(%d+)") 55 - if fg and bg then 56 - -- If foreground is lighter than background, likely dark theme 57 - return tonumber(fg) > tonumber(bg) 43 + -- Check NixOS theme system first (always check this fresh) 44 + local f = io.open("/var/theme/current_theme", "r") 45 + if f then 46 + local content = f:read("*all"):gsub("^%s+", ""):gsub("%s+$", "") 47 + f:close() 48 + is_dark = (content == "dark") 49 + else 50 + -- Fallback to other methods if theme file doesn't exist 51 + local methods = { 52 + -- GNOME/GTK 53 + "gsettings get org.gnome.desktop.interface gtk-theme 2>/dev/null", 54 + "gsettings get org.gnome.desktop.interface color-scheme 2>/dev/null", 55 + -- KDE 56 + "kreadconfig5 --file kdeglobals --group General --key ColorScheme 2>/dev/null", 57 + -- Check if COLORFGBG suggests dark background 58 + function() 59 + local colorfgbg = vim.env.COLORFGBG 60 + if colorfgbg then 61 + local fg, bg = colorfgbg:match("(%d+);(%d+)") 62 + if fg and bg then 63 + -- If foreground is lighter than background, likely dark theme 64 + return tonumber(fg) > tonumber(bg) 65 + end 58 66 end 67 + return false 59 68 end 60 - return false 61 - end 62 - } 69 + } 63 70 64 - for _, method in ipairs(methods) do 65 - if type(method) == "function" then 66 - is_dark = method() 67 - if is_dark then break end 68 - else 69 - local result = vim.fn.system(method) 70 - if result:match("[Dd]ark") or result:match("prefer%-dark") then 71 - is_dark = true 72 - break 71 + for _, method in ipairs(methods) do 72 + if type(method) == "function" then 73 + is_dark = method() 74 + if is_dark then break end 75 + else 76 + local result = vim.fn.system(method) 77 + if result:match("[Dd]ark") or result:match("prefer%-dark") then 78 + is_dark = true 79 + break 80 + end 73 81 end 74 82 end 75 83 end ··· 83 91 84 92 if is_dark then 85 93 vim.cmd("colorscheme ayu") 86 - print("Switched to dark theme (ayu)") 87 94 else 88 95 vim.cmd("colorscheme everforest") 89 - print("Switched to light theme (everforest)") 90 96 end 91 97 end 92 98 end