initial commit
This commit is contained in:
commit
9fde6d4fc6
27 changed files with 1110 additions and 0 deletions
58
modules/Notifications.qml
Normal file
58
modules/Notifications.qml
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import QtQuick
|
||||
import Quickshell.Io
|
||||
import "." as M
|
||||
|
||||
Row {
|
||||
id: root
|
||||
spacing: 4
|
||||
|
||||
property int count: 0
|
||||
property bool dnd: false
|
||||
|
||||
Process {
|
||||
id: sub
|
||||
running: true
|
||||
command: ["swaync-client", "--subscribe-waybar"]
|
||||
stdout: SplitParser {
|
||||
splitMarker: "\n"
|
||||
onRead: (line) => {
|
||||
try {
|
||||
const d = JSON.parse(line);
|
||||
root.count = d.count ?? 0;
|
||||
root.dnd = (d.class ?? "").includes("dnd");
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: {
|
||||
if (root.dnd) return root.count > 0 ? "" : "";
|
||||
return root.count > 0 ? "" : "";
|
||||
}
|
||||
color: M.Theme.base05
|
||||
font.pixelSize: M.Theme.fontSize + 2
|
||||
font.family: M.Theme.fontFamily
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
Text {
|
||||
text: root.count > 0 ? String(root.count) : ""
|
||||
color: M.Theme.base05
|
||||
font.pixelSize: M.Theme.fontSize
|
||||
font.family: M.Theme.fontFamily
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
onClicked: (m) => {
|
||||
const cmd = m.button === Qt.RightButton
|
||||
? ["swaync-client", "--toggle-dnd", "--skip-wait"]
|
||||
: ["swaync-client", "--toggle-panel", "--skip-wait"];
|
||||
clicker.command = cmd;
|
||||
clicker.running = true;
|
||||
}
|
||||
}
|
||||
Process { id: clicker }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue