61 lines
1.6 KiB
QML
61 lines
1.6 KiB
QML
import QtQuick
|
|
import Quickshell.Io
|
|
import "." as M
|
|
|
|
Row {
|
|
id: root
|
|
spacing: 4
|
|
|
|
property int count: 0
|
|
property bool dnd: false
|
|
property bool inhibited: false
|
|
|
|
Process {
|
|
id: sub
|
|
running: true
|
|
command: ["swaync-client", "--subscribe-waybar"]
|
|
stdout: SplitParser {
|
|
splitMarker: "\n"
|
|
onRead: line => {
|
|
try {
|
|
const d = JSON.parse(line);
|
|
const cls = d.class ?? "";
|
|
root.count = d.count ?? 0;
|
|
root.dnd = cls.includes("dnd");
|
|
root.inhibited = cls.includes("inhibited");
|
|
} catch (e) {}
|
|
}
|
|
}
|
|
}
|
|
|
|
M.BarIcon {
|
|
icon: {
|
|
if (root.inhibited) return root.count > 0 ? "\uDB80\uDC9B" : "\uDB82\uDE91";
|
|
if (root.dnd) return root.count > 0 ? "\uDB80\uDCA0" : "\uDB82\uDE93";
|
|
return root.count > 0 ? "\uDB84\uDD6B" : "\uDB80\uDC9C";
|
|
}
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
M.BarLabel {
|
|
label: root.count > 0 ? String(root.count) : ""
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
|
|
TapHandler {
|
|
acceptedButtons: Qt.LeftButton
|
|
onTapped: {
|
|
clicker.command = ["swaync-client", "--toggle-panel", "--skip-wait"];
|
|
clicker.running = true;
|
|
}
|
|
}
|
|
TapHandler {
|
|
acceptedButtons: Qt.RightButton
|
|
onTapped: {
|
|
clicker.command = ["swaync-client", "--toggle-dnd", "--skip-wait"];
|
|
clicker.running = true;
|
|
}
|
|
}
|
|
Process {
|
|
id: clicker
|
|
}
|
|
}
|