From a3ca244c15056377ec33a3180ff9db881fe77c35 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sun, 27 Jul 2025 22:59:45 +1000 Subject: bar: add kb layout status icon Closes #280 --- services/Hyprland.qml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'services') diff --git a/services/Hyprland.qml b/services/Hyprland.qml index 1385723..2b3fd32 100644 --- a/services/Hyprland.qml +++ b/services/Hyprland.qml @@ -2,6 +2,7 @@ pragma Singleton import Quickshell import Quickshell.Hyprland +import Quickshell.Io import QtQuick Singleton { @@ -14,6 +15,7 @@ Singleton { readonly property HyprlandWorkspace focusedWorkspace: Hyprland.focusedWorkspace readonly property HyprlandMonitor focusedMonitor: Hyprland.focusedMonitor readonly property int activeWsId: focusedWorkspace?.id ?? 1 + property string kbLayout: "?" function dispatch(request: string): void { Hyprland.dispatch(request); @@ -27,7 +29,9 @@ Singleton { if (n.endsWith("v2")) return; - if (["workspace", "moveworkspace", "activespecial", "focusedmon"].includes(n)) { + if (n === "activelayout") { + root.kbLayout = event.parse(2)[1]; + } else if (["workspace", "moveworkspace", "activespecial", "focusedmon"].includes(n)) { Hyprland.refreshWorkspaces(); Hyprland.refreshMonitors(); } else if (["openwindow", "closewindow", "movewindow"].includes(n)) { @@ -42,4 +46,12 @@ Singleton { } } } + + Process { + running: true + command: ["hyprctl", "-j", "devices"] + stdout: StdioCollector { + onStreamFinished: root.kbLayout = JSON.parse(text).keyboards.find(k => k.main).layout + } + } } -- cgit v1.2.3-freya