repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

quickshell/nugu/NotificationBridgeWidget.qml

Raw
import QtQuick
import Quickshell.Io
import "."

StatusItem {
    id: root

    required property QtObject commands

    property int count: 0

    text: count > 0 ? `󰂞 ${count}` : "󰂚"
    active: count > 0
    minWidth: count > 0 ? 42 : 24

    // Mako remains the notification daemon in Phase 2C. Polling is temporary and
    // intentionally isolated so Phase 3 can swap in native notification state.
    onLeftClicked: commands.restoreNotification()
    onRightClicked: commands.dismissNotifications()

    Timer {
        running: true
        repeat: true
        interval: 5000
        triggeredOnStart: true
        onTriggered: poll.exec(["sh", "-c", "makoctl list 2>/dev/null | grep -c '^Notification '"])
    }

    Process {
        id: poll
        stdout: StdioCollector {
            onStreamFinished: root.count = parseInt(this.text.trim() || "0", 10)
        }
    }
}