This commit is contained in:
Mikhail Kilin
2026-06-21 16:22:06 +03:00
parent 698c953c55
commit 8cedd606f5
58 changed files with 4333 additions and 146 deletions

View File

@@ -1,24 +1,23 @@
local layout = "EN"
local function update_layout()
vim.system({ "im-select" }, { text = true }, function(result)
if result.stdout then
layout = result.stdout:find("Russian") and "RU" or "EN"
end
end)
end
-- Update layout in background every second, never blocks UI
local timer = vim.loop.new_timer()
timer:start(0, 1000, vim.schedule_wrap(update_layout))
local function keyboard_layout()
local handle = io.popen("im-select")
if not handle then
return ""
end
local result = handle:read("*a")
handle:close()
if result:find("Russian") then
return "RU"
end
return "EN"
return layout
end
local function keyboard_layout_color()
local handle = io.popen("im-select")
if not handle then
return { bg = "#a6e3a1", fg = "#1e1e2e", gui = "bold" }
end
local result = handle:read("*a")
handle:close()
if result:find("Russian") then
if layout == "RU" then
return { bg = "#f38ba8", fg = "#1e1e2e", gui = "bold" }
end
return { bg = "#a6e3a1", fg = "#1e1e2e", gui = "bold" }