Simplify
This commit is contained in:
@@ -1,51 +1,22 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell.Io
|
|
||||||
import qs.Commons
|
import qs.Commons
|
||||||
import qs.Ui
|
import qs.Ui
|
||||||
|
|
||||||
BarIndicator {
|
BarIndicator {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property string statusText: ""
|
readonly property var notificationService: bar.shell.firstPartyServiceFor("omarchy.notifications")
|
||||||
property string statusTooltip: ""
|
readonly property bool dnd: notificationService ? notificationService.doNotDisturb : false
|
||||||
|
|
||||||
active: statusText !== ""
|
active: dnd
|
||||||
activeText: statusText
|
activeText: ""
|
||||||
inactiveText: ""
|
inactiveText: ""
|
||||||
activeTooltipText: statusTooltip
|
activeTooltipText: "Notifications silenced"
|
||||||
inactiveTooltipText: "Do Not Disturb"
|
inactiveTooltipText: "Do Not Disturb"
|
||||||
|
|
||||||
function refresh() {
|
onPressed: function() {
|
||||||
if (!root.bar || statusProc.running) return
|
if (root.notificationService) {
|
||||||
statusProc.command = ["bash", "-lc", Util.shellQuote(root.bar.omarchyPath + "/shell/scripts/indicators/notification-silencing.sh")]
|
root.notificationService.setDoNotDisturb(!root.notificationService.doNotDisturb)
|
||||||
statusProc.running = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function update(raw) {
|
|
||||||
var data = extractData(raw)
|
|
||||||
|
|
||||||
statusText = data.text || ""
|
|
||||||
statusTooltip = data.tooltip || ""
|
|
||||||
}
|
|
||||||
|
|
||||||
onBarChanged: refresh()
|
|
||||||
Component.onCompleted: refresh()
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: root.bar
|
|
||||||
ignoreUnknownSignals: true
|
|
||||||
function onIndicatorsRefreshRequested() { root.refresh() }
|
|
||||||
}
|
|
||||||
|
|
||||||
Process {
|
|
||||||
id: statusProc
|
|
||||||
stdout: StdioCollector {
|
|
||||||
waitForEnd: true
|
|
||||||
onStreamFinished: root.update(text)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onPressed: function() {
|
|
||||||
if (root.bar) root.bar.run("omarchy-toggle-notification-silencing")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
state=$(omarchy-shell notifications isDnd 2>/dev/null || echo off)
|
|
||||||
if [[ $state == "on" ]]; then
|
|
||||||
echo '{"text": "", "tooltip": "Notifications silenced", "class": "active"}'
|
|
||||||
else
|
|
||||||
echo '{"text": ""}'
|
|
||||||
fi
|
|
||||||
Reference in New Issue
Block a user