-- 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