48 lines
1.2 KiB
Lua
48 lines
1.2 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.vconsole()
|
|
return read_values("/etc/vconsole.conf")
|
|
end
|
|
|
|
function keyboard.installed()
|
|
local values = keyboard.vconsole()
|
|
if read_values("/etc/omarchy/input-method").XKB_LAYOUT == "kr" then
|
|
values.XKBLAYOUT, values.XKBVARIANT = "kr", ""
|
|
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.installed().XKBLAYOUT or "us"
|
|
return layout:match("^[^,]*") == "jp"
|
|
end
|
|
|
|
return keyboard
|