This commit is contained in:
Zacharias-Brohn
2025-11-09 01:14:25 +01:00
parent 176b5c79b7
commit 6e58104d05
2 changed files with 1 additions and 95 deletions
+1 -1
View File
@@ -103,7 +103,7 @@ Scope {
Layout.alignment: Qt.AlignVCenter
text: "\ue7f4"
font.family: "Material Symbols Rounded"
font.pixelSize: 22
font.pixelSize: 20
color: "white"
MouseArea {
anchors.fill: parent
-94
View File
@@ -1,94 +0,0 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Quickshell
import Quickshell.Io
Item {
id: root
implicitWidth: notificationButton.implicitWidth
implicitHeight: notificationButton.implicitHeight
property var notificationState: ({})
function updateState(output) {
try {
notificationState = JSON.parse(output.trim())
} catch (e) {
console.error("Failed to parse swaync state:", e)
}
}
function getIcon() {
let count = notificationState["text"] || 0
let hasNotification = count > 0
if (hasNotification) return "notification"
return "none"
}
function getDisplayText() {
let icon = getIcon()
let count = notificationState["count"] || 0
if (icon.includes("notification")) {
return ""
}
return ""
}
Process {
id: swayNcMonitor
running: true
command: ["swaync-client", "-swb"]
stdout: SplitParser {
onRead: data => root.updateState(data)
}
}
Process {
id: swayncProcess
command: ["sh", "-c", "qs -p /home/zach/GitProjects/z-bar-qt/notification-test/shell.qml ipc call root showCenter"]
running: false
}
Button {
id: notificationButton
flat: true
background: Rectangle {
color: "transparent"
radius: 4
}
contentItem: RowLayout {
spacing: 0
Text {
text: root.getDisplayText()
color: "white"
font.pixelSize: 16
Layout.alignment: Qt.AlignVCenter
}
Text {
text: "●"
color: "red"
font.pixelSize: 6
visible: root.getIcon().includes("notification")
Layout.alignment: Qt.AlignTop | Qt.AlignRight
Layout.topMargin: 0
Layout.rightMargin: 4
}
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
swayncProcess.running = true
}
}
}
}