Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
959cbab
settings: keyboard backend for hardware and on-screen layouts
Somnius Nov 17, 2026
b503a1d
settings: install the keyboard backend and run its test
Somnius Nov 17, 2026
e5ffa8b
settings: keyboard page with layouts, order and switch key
Somnius Nov 17, 2026
a83ca73
shell: omamobile-keyboard-switch and the layout follower
Somnius Nov 17, 2026
64c262b
bar: keyboard layout label beside the clock
Somnius Nov 17, 2026
a474029
settings: keyboard backend handles Omarchy's stock input.lua
Somnius Nov 17, 2026
bb60382
settings: core tests know the keyboard row and page
Somnius Nov 17, 2026
e27a9c6
shell: one main-keyboard rule, safe batch names, listener syncs keybo…
Somnius Nov 17, 2026
c81ef94
settings: keyboard backend merges the OSK list, refuses non-Latin first
Somnius Nov 17, 2026
aca06b3
keyboard: switch key is a Hyprland bind, no OSK writes on a switch
Somnius Nov 17, 2026
90a8482
shell: no on-screen keyboard pop-up while a hardware keyboard is conn…
Somnius Nov 17, 2026
4a901a4
keyboard: switch binds on release and never unbind user keys; guard c…
Somnius Nov 17, 2026
5290a65
keyboard: press binds for Alt/Ctrl+Shift, xkb caps_toggle for Caps Lock
Somnius Nov 17, 2026
e8b5300
keyboard: put compose:caps back when caps lets go of the switch key, …
Somnius Nov 17, 2026
1cf3fb3
keyboard: no default switch binds under an xkb grp: option, keep the …
Somnius Nov 17, 2026
4026826
keyboard: switch keys through xkb only
Somnius Nov 18, 2026
da2bdd7
keyboard: Omarchy 4.5's omarchy:shift_caps_compose goes with a Caps s…
Somnius Nov 18, 2026
4f851a3
docs: keyboard page, bar label, keyboard card and switch delay chart …
Somnius Nov 18, 2026
3aac25f
keyboard: every Compose option on Caps is remembered and put back, a …
Somnius Nov 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/screenshots/keyboard/bar-label.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screenshots/keyboard/kbd-card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screenshots/keyboard/kbd-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screenshots/keyboard/switch-delay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
152 changes: 152 additions & 0 deletions packages/omamobile-settings/app/KeyboardPage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
// SPDX-License-Identifier: MIT
// Keyboard layouts (up to 4) and the hardware switch key, through backends/keyboard.sh. Each change is
// saved and applied at once; new layouts are added to the on-screen keyboard's list, and the switch key is an xkb grp: option in kb_options.
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import "."
Flickable {
id: page
clip: true
contentWidth: width; contentHeight: col.implicitHeight
boundsBehavior: Flickable.StopAtBounds
property var layouts: [] // ["us", "gr:polytonic"], index 0 = main layout
property string switchKey: ""
property var available: [] // [{layout, name}]
property var switchKeys: [] // [{option, name}]
property string status: qsTr("Reading the keyboard settings...")
property string warn: ""
property bool busy: true
property int reqId: -1
property int listId: -1
readonly property int maxLayouts: 4
// Same set as LATIN in backends/keyboard.sh
readonly property var latin: ["us", "gb", "de", "fr", "es", "it", "pt", "nl", "be", "ch", "at", "se", "no", "dk", "fi",
"is", "ie", "pl", "cz", "sk", "hu", "ro", "hr", "si", "ee", "lv", "lt", "tr", "br", "latam",
"ca", "au", "nz", "za", "epo"]
function nameOf(code) {
const l = code.split(":")[0], v = code.split(":")[1] || ""
for (const a of available) if (a.layout === l) return v ? a.name + " (" + v + ")" : a.name
return code
}
function keyName(opt) {
for (const k of switchKeys) if (k.option === opt) return k.name
return opt
}
property string lastError: "" // shown after the re-read that follows a failed set
function isLatin(code) { return latin.indexOf(code.split(":")[0]) >= 0 }
function apply(r) {
busy = false
if (r.error) {
// A set can fail half way (file saved, live apply or OSK not): read the real state again so
// the next change is not built from a stale list, and keep the error on screen.
if (lastError === "") { lastError = r.error; status = r.error; busy = true; reqId = actions.run("keyboard", ["get"]) }
else { status = lastError; lastError = "" }
return
}
if (!r.layouts) { status = qsTr("The keyboard backend gave no values."); return }
layouts = r.layouts.map(x => x.variant ? x.layout + ":" + x.variant : x.layout)
switchKey = r.switchKey || ""
warn = layouts.length && !isLatin(layouts[0])
? qsTr("The first layout is not a Latin one: passwords on the lock screen are typed in it") : ""
status = lastError !== "" ? lastError : qsTr("Changes apply at once to hardware keyboards and the on-screen keyboard.")
lastError = ""
}
function save(list) {
filter.text = ""
// The backend refuses this too; stop here so nothing is sent.
if (!list.length || !isLatin(list[0])) {
status = qsTr("The first layout must be a Latin one: passwords on the lock screen are typed in it.")
return
}
busy = true
reqId = actions.run("keyboard", ["set", "layouts", list.join(",")])
}
function move(i, d) {
const l = layouts.slice(), j = i + d
if (j < 0 || j >= l.length) return
const t = l[i]; l[i] = l[j]; l[j] = t
save(l)
}
function remove(i) { const l = layouts.slice(); l.splice(i, 1); save(l) }
function add(code) { if (layouts.indexOf(code) < 0) save(layouts.concat([code])) }
Connections {
target: actions
function onFinished(tool, r, id) {
if (tool !== "keyboard") return
if (id === page.listId) { page.available = r.layouts || []; page.switchKeys = r.switchKeys || [] }
else if (id === page.reqId) page.apply(r)
}
}
Component.onCompleted: { listId = actions.run("keyboard", ["list"]); reqId = actions.run("keyboard", ["get"]) }
ColumnLayout {
id: col
width: page.width
spacing: 14
SettingsLabel { text: qsTr("Layouts"); font.weight: Font.DemiBold; color: backend.foreground; Layout.fillWidth: true }
Repeater {
model: page.layouts
delegate: RowLayout {
required property string modelData
required property int index
Layout.fillWidth: true; spacing: 8
SettingsLabel {
text: (index + 1) + ". " + page.nameOf(modelData)
color: backend.foreground; wrapMode: Text.Wrap; Layout.fillWidth: true
}
SettingsButton { text: "↑"; enabled: !page.busy && index > 0; onClicked: page.move(index, -1); Accessible.name: qsTr("Move up") }
SettingsButton { text: "↓"; enabled: !page.busy && index < page.layouts.length - 1; onClicked: page.move(index, 1); Accessible.name: qsTr("Move down") }
SettingsButton { text: "✕"; enabled: !page.busy && page.layouts.length > 1; onClicked: page.remove(index); Accessible.name: qsTr("Remove") }
}
}
SettingsLabel {
visible: page.warn !== ""
text: "⚠ " + page.warn
color: backend.foreground; wrapMode: Text.Wrap; Layout.fillWidth: true
}
// Add a layout: a search field, with matches shown as you type (the full list is ~100 long).
SettingsTextField {
id: filter
visible: page.layouts.length < page.maxLayouts
enabled: !page.busy && page.available.length > 0
Layout.fillWidth: true; Layout.preferredHeight: 52
placeholderText: qsTr("Add a layout: type a language or country")
color: backend.foreground; placeholderTextColor: backend.muted
background: Rectangle { radius: Math.min(backend.radius, width / 2, height / 2); color: SettingsStyle.fill("normal") }
}
Repeater {
model: filter.visible && filter.text.trim() !== "" ? page.available.filter(a => {
const q = filter.text.trim().toLowerCase()
return page.layouts.indexOf(a.layout) < 0 && (a.name.toLowerCase().indexOf(q) >= 0 || a.layout.indexOf(q) >= 0)
}).slice(0, 12) : []
delegate: SettingsButton {
required property var modelData
Layout.fillWidth: true
text: modelData.name + " (" + modelData.layout + ")"
enabled: !page.busy
onClicked: page.add(modelData.layout)
}
}
SettingsLabel {
visible: page.layouts.length > 1
text: qsTr("Switch key (hardware keyboard)"); font.weight: Font.DemiBold; color: backend.foreground
Layout.fillWidth: true; Layout.topMargin: 8
}
Flow {
visible: page.layouts.length > 1
Layout.fillWidth: true; spacing: 8
Repeater {
// From `keyboard.sh list`: Alt+Shift, Ctrl+Shift, Caps Lock, None (grp:alt_shift_toggle, grp:ctrl_shift_toggle, grp:caps_toggle, no grp:)
model: page.switchKeys
delegate: SettingsButton {
required property var modelData
text: modelData.name
highlighted: page.switchKey === modelData.option
enabled: !page.busy
onClicked: { page.busy = true; page.reqId = actions.run("keyboard", ["set", "switch-key", modelData.option]) }
}
}
}
SettingsLabel { text: page.status; color: backend.muted; font.pixelSize: SettingsStyle.fontPx(13); wrapMode: Text.Wrap; Layout.fillWidth: true }
}
}
2 changes: 1 addition & 1 deletion packages/omamobile-settings/app/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ApplicationWindow {
if (backend.searching) search.clear()
backend.back()
}
readonly property var customPages: ({ display: "DisplayPage.qml" })
readonly property var customPages: ({ display: "DisplayPage.qml", keyboard: "KeyboardPage.qml" })
readonly property string customSource: backend.searching ? "" : (customPages[backend.page] || "")
readonly property bool showingAbout: backend.page === "about" && !backend.searching
Connections {
Expand Down
9 changes: 6 additions & 3 deletions packages/omamobile-settings/app/actionrunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ void ActionRunner::post(const QString &tool, const QVariantMap &result, int id)

int ActionRunner::run(const QString &tool, const QStringList &args) {
static const QRegularExpression word("\\A[a-z0-9]{1,16}\\z");
static const QStringList tools = {"display"};
// keyboard takes layout lists (us,gr:polytonic), and switch-key names (alt_shift, ctrl_shift, caps, none)
static const QRegularExpression kbdWord("\\A[a-z][a-z0-9_:,-]{0,159}\\z");
static const QStringList tools = {"display", "keyboard"};
const int id = ++m_next;
auto fail = [this, &tool, id](const QString &why) { post(tool, {{"error", why}}, id); return id; };
if (!tools.contains(tool) || args.size() > 3) return fail("unknown action");
for (const auto &a : args) if (!word.match(a).hasMatch()) return fail("bad argument");
const auto &allowed = tool == "keyboard" ? kbdWord : word;
for (const auto &a : args) if (!allowed.match(a).hasMatch()) return fail("bad argument");
const QString dir = "/usr/lib/omamobile-settings/backends";
auto *p = new QProcess(this);
// bash would run a startup file named by these
Expand All @@ -31,7 +34,7 @@ int ActionRunner::run(const QString &tool, const QStringList &args) {
p->setProgram("/usr/bin/bash");
p->setArguments(QStringList{dir + "/" + tool + ".sh"} + args);
connect(p, &QProcess::finished, this, [this, p, tool, id](int code, QProcess::ExitStatus st) {
const auto raw = p->readAllStandardOutput().left(4096);
const auto raw = p->readAllStandardOutput().left(32768);
p->readAllStandardError();
auto obj = QJsonDocument::fromJson(raw).object();
if (obj.isEmpty() || st != QProcess::NormalExit)
Expand Down
2 changes: 1 addition & 1 deletion packages/omamobile-settings/app/actionrunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <QVariantMap>
#include <QStringList>

// Runs the source-owned backend scripts (display) with a fixed argument list and no shell. Pages call run();
// Runs the source-owned backend scripts (display, keyboard) with a fixed argument list and no shell. Pages call run();
// the JSON the script prints comes back through finished(), always from the event loop and never before run()
// has returned its id.
class ActionRunner : public QObject {
Expand Down
11 changes: 11 additions & 0 deletions packages/omamobile-settings/app/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
"icon": "display",
"page": "display"
},
{
"id": "keyboard",
"title": "Keyboard",
"detail": "Layouts and the switch key",
"icon": "keyboard",
"page": "keyboard"
},
{
"id": "about",
"title": "About this device",
Expand All @@ -25,5 +32,9 @@
"display": {
"title": "Display",
"rows": []
},
"keyboard": {
"title": "Keyboard",
"rows": []
}
}
1 change: 1 addition & 0 deletions packages/omamobile-settings/app/icons/keyboard.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions packages/omamobile-settings/app/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<file>Main.qml</file>
<file>AboutPage.qml</file>
<file>DisplayPage.qml</file>
<file>KeyboardPage.qml</file>
<file>icons/keyboard.svg</file>
<file>icons/display.svg</file>
<file>catalog.json</file>
<file>icons/system.svg</file>
Expand Down
Loading