bar: add kblayout popout
This commit is contained in:
parent
e60fa05504
commit
660f09959d
4 changed files with 17 additions and 7 deletions
|
|
@ -42,11 +42,9 @@ StyledRect {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keyboard layout icon
|
// Keyboard layout icon
|
||||||
Loader {
|
WrappedLoader {
|
||||||
Layout.alignment: Qt.AlignHCenter
|
name: "kblayout"
|
||||||
asynchronous: true
|
|
||||||
active: Config.bar.status.showKbLayout
|
active: Config.bar.status.showKbLayout
|
||||||
visible: active
|
|
||||||
|
|
||||||
sourceComponent: StyledText {
|
sourceComponent: StyledText {
|
||||||
animate: true
|
animate: true
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,11 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Popout {
|
||||||
|
name: "kblayout"
|
||||||
|
source: "KbLayout.qml"
|
||||||
|
}
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: ScriptModel {
|
model: ScriptModel {
|
||||||
values: [...SystemTray.items.values]
|
values: [...SystemTray.items.values]
|
||||||
|
|
|
||||||
6
modules/bar/popouts/KbLayout.qml
Normal file
6
modules/bar/popouts/KbLayout.qml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import qs.components
|
||||||
|
import qs.services
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: qsTr("Keyboard layout: %1").arg(Hyprland.kbLayoutFull)
|
||||||
|
}
|
||||||
|
|
@ -15,7 +15,8 @@ Singleton {
|
||||||
readonly property HyprlandWorkspace focusedWorkspace: Hyprland.focusedWorkspace
|
readonly property HyprlandWorkspace focusedWorkspace: Hyprland.focusedWorkspace
|
||||||
readonly property HyprlandMonitor focusedMonitor: Hyprland.focusedMonitor
|
readonly property HyprlandMonitor focusedMonitor: Hyprland.focusedMonitor
|
||||||
readonly property int activeWsId: focusedWorkspace?.id ?? 1
|
readonly property int activeWsId: focusedWorkspace?.id ?? 1
|
||||||
property string kbLayout: "?"
|
readonly property string kbLayout: kbLayoutFull.slice(0, 2).toLowerCase()
|
||||||
|
property string kbLayoutFull: "?"
|
||||||
|
|
||||||
function dispatch(request: string): void {
|
function dispatch(request: string): void {
|
||||||
Hyprland.dispatch(request);
|
Hyprland.dispatch(request);
|
||||||
|
|
@ -34,7 +35,7 @@ Singleton {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (n === "activelayout") {
|
if (n === "activelayout") {
|
||||||
root.kbLayout = event.parse(2)[1].slice(0, 2).toLowerCase();
|
root.kbLayoutFull = event.parse(2)[1];
|
||||||
} else if (["workspace", "moveworkspace", "activespecial", "focusedmon"].includes(n)) {
|
} else if (["workspace", "moveworkspace", "activespecial", "focusedmon"].includes(n)) {
|
||||||
Hyprland.refreshWorkspaces();
|
Hyprland.refreshWorkspaces();
|
||||||
Hyprland.refreshMonitors();
|
Hyprland.refreshMonitors();
|
||||||
|
|
@ -55,7 +56,7 @@ Singleton {
|
||||||
running: true
|
running: true
|
||||||
command: ["hyprctl", "-j", "devices"]
|
command: ["hyprctl", "-j", "devices"]
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
onStreamFinished: root.kbLayout = JSON.parse(text).keyboards.find(k => k.main).active_keymap.slice(0, 2).toLowerCase()
|
onStreamFinished: root.kbLayoutFull = JSON.parse(text).keyboards.find(k => k.main).active_keymap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue