add quickshell
This commit is contained in:
parent
3d48e35de5
commit
10960f620d
32 changed files with 1415 additions and 11 deletions
69
quickshell/KeyboardLayout.qml
Normal file
69
quickshell/KeyboardLayout.qml
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import QtQuick
|
||||
|
||||
BarPill {
|
||||
id: root
|
||||
|
||||
property int currentIdx: 0
|
||||
property var names: []
|
||||
|
||||
readonly property string shortName: {
|
||||
if (names.length === 0) return "??"
|
||||
const n = names[currentIdx] ?? ""
|
||||
if (n.includes("Portuguese")) return "PT"
|
||||
if (n.includes("English")) return "EN"
|
||||
// fallback: first two chars of first word
|
||||
return n.split(" ")[0].substring(0, 2).toUpperCase()
|
||||
}
|
||||
|
||||
Process {
|
||||
command: ["niri", "msg", "--json", "keyboard-layouts"]
|
||||
running: true
|
||||
stdout: SplitParser {
|
||||
splitMarker: ""
|
||||
onRead: data => {
|
||||
try {
|
||||
const kl = JSON.parse(data)
|
||||
root.currentIdx = kl.current_idx
|
||||
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
|
||||
root.currentIdx = kl.current_idx
|
||||
root.names = kl.names
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: ""
|
||||
color: Theme.purple
|
||||
font.pixelSize: Theme.fontSize
|
||||
font.family: Theme.font
|
||||
}
|
||||
Text {
|
||||
text: root.shortName
|
||||
color: Theme.text
|
||||
font.pixelSize: Theme.fontSize
|
||||
font.family: Theme.font
|
||||
|
||||
Behavior on text {
|
||||
// Flash the label on layout change
|
||||
SequentialAnimation {
|
||||
PropertyAnimation { target: parent; property: "opacity"; to: 0; duration: 80 }
|
||||
PropertyAction { target: parent; property: "text" }
|
||||
PropertyAnimation { target: parent; property: "opacity"; to: 1; duration: 80 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue