Files
omarchy/default/hypr/keyboard.lua
T
David Heinemeier HanssonandClaude Opus 5.5 87c4e2c8b1 Give the Lao keyboard choice a Lao desktop layout
The row used la-latin1, kbd's Latin American Spanish keymap, so Lao
installs typed Spanish. There is no Lao console keymap; like Korean, the
console stays US and the desktop gets la, which Omarchy keeps behind US
as a non-Latin layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 07:32:34 +09:00

62 lines
1.8 KiB
Lua

-- The keyboard layout picked at install time. The installer and first-boot
-- setup persist it to /etc/vconsole.conf, so Hyprland reads it from there
-- instead of rewriting every user's config.
local keyboard = {}
local function read_values(path)
local values = {}
local file = io.open(path, "r")
if not file then
return values
end
for line in file:lines() do
local key, value = line:match("^%s*([%w_]+)%s*=%s*(.-)%s*$")
if key and value then
value = value:gsub("%s+#.*$", "")
value = value:gsub('^"(.*)"$', "%1")
value = value:gsub("^'(.*)'$", "%1")
values[key] = value
end
end
file:close()
return values
end
function keyboard.selected()
local paths = require("default.hypr.paths")
local values = read_values(paths.config_home .. "/omarchy/keyboard-layouts")
if values.XKBLAYOUT then return values end
return keyboard.installed()
end
function keyboard.vconsole()
return read_values("/etc/vconsole.conf")
end
-- Choices whose console keymap is plain US but whose desktop layout is not:
-- Korean keeps US letters, and Lao is non-Latin, so US still leads.
local desktop_overrides = { kr = true, la = true }
function keyboard.installed()
local values = keyboard.vconsole()
local override = read_values("/etc/omarchy/input-method").XKB_LAYOUT
if desktop_overrides[override]
and (values.XKBLAYOUT or "us") == "us"
and (values.XKBVARIANT or "") == "" then
values.XKBLAYOUT, values.XKBVARIANT = override, ""
end
return values
end
-- Japanese (JIS) keyboards put +, ^, and the Henkan/Muhenkan keys where US
-- keyboards don't, so a few defaults only apply when that layout leads.
function keyboard.jis()
local layout = keyboard.selected().XKBLAYOUT or "us"
return layout:match("^[^,]*") == "jp"
end
return keyboard