hypr: account for kb layout variants (#836)
Refactor layout and variant parsing logic in Hypr.qml to improve readability and maintainability.
This commit is contained in:
parent
58ac60c47c
commit
223207235e
1 changed files with 23 additions and 7 deletions
|
|
@ -110,14 +110,30 @@ Singleton {
|
||||||
|
|
||||||
path: Quickshell.env("CAELESTIA_XKB_RULES_PATH") || "/usr/share/X11/xkb/rules/base.lst"
|
path: Quickshell.env("CAELESTIA_XKB_RULES_PATH") || "/usr/share/X11/xkb/rules/base.lst"
|
||||||
onLoaded: {
|
onLoaded: {
|
||||||
const lines = text().match(/! layout\n([\s\S]*?)\n\n/)[1].split("\n");
|
const layoutMatch = text().match(/! layout\n([\s\S]*?)\n\n/);
|
||||||
for (const line of lines) {
|
if (layoutMatch) {
|
||||||
if (!line.trim() || line.trim().startsWith("!"))
|
const lines = layoutMatch[1].split("\n");
|
||||||
continue;
|
for (const line of lines) {
|
||||||
|
if (!line.trim() || line.trim().startsWith("!"))
|
||||||
|
continue;
|
||||||
|
|
||||||
const match = line.match(/^\s*([a-z]{2,})\s+([a-zA-Z() ]+)$/);
|
const match = line.match(/^\s*([a-z]{2,})\s+([a-zA-Z() ]+)$/);
|
||||||
if (match)
|
if (match)
|
||||||
root.kbMap.set(match[2], match[1]);
|
root.kbMap.set(match[2], match[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const variantMatch = text().match(/! variant\n([\s\S]*?)\n\n/);
|
||||||
|
if (variantMatch) {
|
||||||
|
const lines = variantMatch[1].split("\n");
|
||||||
|
for (const line of lines) {
|
||||||
|
if (!line.trim() || line.trim().startsWith("!"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const match = line.match(/^\s*([a-zA-Z0-9_-]+)\s+([a-z]{2,}): (.+)$/);
|
||||||
|
if (match)
|
||||||
|
root.kbMap.set(match[3], match[2]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue