fix lang change hotkey
This commit is contained in:
parent
b41168aaaf
commit
90dd142107
2 changed files with 16 additions and 23 deletions
|
|
@ -53,8 +53,7 @@ in {
|
||||||
input {
|
input {
|
||||||
keyboard {
|
keyboard {
|
||||||
xkb {
|
xkb {
|
||||||
layout "us,pt"
|
layout "us,br"
|
||||||
variant ",br"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
touchpad {
|
touchpad {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import QtQuick
|
||||||
|
|
||||||
BarPill {
|
BarPill {
|
||||||
id: root
|
id: root
|
||||||
|
layer.enabled: true
|
||||||
|
|
||||||
property int currentIdx: 0
|
property int currentIdx: 0
|
||||||
property var names: []
|
property var names: []
|
||||||
|
|
@ -18,32 +19,24 @@ BarPill {
|
||||||
}
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
command: ["niri", "msg", "--json", "keyboard-layouts"]
|
command: ["niri", "msg", "--json", "event-stream"]
|
||||||
running: true
|
running: true
|
||||||
stdout: SplitParser {
|
stdout: SplitParser {
|
||||||
splitMarker: ""
|
splitMarker: "\n"
|
||||||
onRead: data => {
|
onRead: data => {
|
||||||
try {
|
try {
|
||||||
const kl = JSON.parse(data)
|
const ev = JSON.parse(data)
|
||||||
root.currentIdx = kl.current_idx
|
if (ev.KeyboardLayoutsChanged) {
|
||||||
root.names = kl.names
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: niri
|
|
||||||
function onRawEventReceived(event) {
|
|
||||||
try {
|
|
||||||
const ev = JSON.parse(event)
|
|
||||||
if (!ev.KeyboardLayoutsChanged) return
|
|
||||||
const kl = ev.KeyboardLayoutsChanged.keyboard_layouts
|
const kl = ev.KeyboardLayoutsChanged.keyboard_layouts
|
||||||
root.currentIdx = kl.current_idx
|
root.currentIdx = kl.current_idx
|
||||||
root.names = kl.names
|
root.names = kl.names
|
||||||
|
} else if (ev.KeyboardLayoutSwitched) {
|
||||||
|
root.currentIdx = ev.KeyboardLayoutSwitched.idx
|
||||||
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: ""
|
text: ""
|
||||||
|
|
@ -52,6 +45,7 @@ BarPill {
|
||||||
font.family: Theme.font
|
font.family: Theme.font
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
|
id: shortNameText
|
||||||
text: root.shortName
|
text: root.shortName
|
||||||
color: Theme.text
|
color: Theme.text
|
||||||
font.pixelSize: Theme.fontSize
|
font.pixelSize: Theme.fontSize
|
||||||
|
|
@ -60,9 +54,9 @@ BarPill {
|
||||||
Behavior on text {
|
Behavior on text {
|
||||||
// Flash the label on layout change
|
// Flash the label on layout change
|
||||||
SequentialAnimation {
|
SequentialAnimation {
|
||||||
PropertyAnimation { target: parent; property: "opacity"; to: 0; duration: 80 }
|
PropertyAnimation { target: shortNameText; property: "opacity"; to: 0; duration: 80 }
|
||||||
PropertyAction { target: parent; property: "text" }
|
PropertyAction { target: shortNameText; property: "text" }
|
||||||
PropertyAnimation { target: parent; property: "opacity"; to: 1; duration: 80 }
|
PropertyAnimation { target: shortNameText; property: "opacity"; to: 1; duration: 80 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue