Simplify
This commit is contained in:
@@ -1,33 +1,24 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import qs.Commons
|
|
||||||
import qs.Ui
|
import qs.Ui
|
||||||
|
|
||||||
BarIndicator {
|
BarIndicator {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property string statusText: ""
|
property bool recording: false
|
||||||
property string statusTooltip: ""
|
|
||||||
|
|
||||||
active: statusText !== ""
|
active: recording
|
||||||
activeText: statusText
|
activeText: ""
|
||||||
inactiveText: ""
|
inactiveText: ""
|
||||||
activeTooltipText: statusTooltip
|
activeTooltipText: "Stop recording"
|
||||||
inactiveTooltipText: "Screen recording"
|
inactiveTooltipText: "Screen recording"
|
||||||
|
|
||||||
function refresh() {
|
function refresh() {
|
||||||
if (!root.bar || statusProc.running) return
|
if (!root.bar || statusProc.running) return
|
||||||
statusProc.command = ["bash", "-lc", Util.shellQuote(root.bar.omarchyPath + "/shell/scripts/indicators/screen-recording.sh")]
|
statusProc.command = ["pgrep", "--quiet", "-f", "^gpu-screen-recorder"]
|
||||||
statusProc.running = true
|
statusProc.running = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function update(raw) {
|
|
||||||
var data = extractData(raw)
|
|
||||||
|
|
||||||
statusText = data.text || ""
|
|
||||||
statusTooltip = data.tooltip || ""
|
|
||||||
}
|
|
||||||
|
|
||||||
onBarChanged: refresh()
|
onBarChanged: refresh()
|
||||||
Component.onCompleted: refresh()
|
Component.onCompleted: refresh()
|
||||||
|
|
||||||
@@ -39,9 +30,8 @@ BarIndicator {
|
|||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: statusProc
|
id: statusProc
|
||||||
stdout: StdioCollector {
|
onExited: function(exitCode) {
|
||||||
waitForEnd: true
|
root.recording = exitCode === 0
|
||||||
onStreamFinished: root.update(text)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if pgrep -f "^gpu-screen-recorder" >/dev/null; then
|
|
||||||
echo '{"text": "", "tooltip": "Stop recording", "class": "active"}'
|
|
||||||
else
|
|
||||||
echo '{"text": ""}'
|
|
||||||
fi
|
|
||||||
Reference in New Issue
Block a user