From 7a9fce9dd417db42d75dc80a86df45ed0402d6d4 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Mon, 15 Sep 2025 21:55:10 +1000 Subject: utilities/record: allow pause/resume recording --- services/Recorder.qml | 60 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 8 deletions(-) (limited to 'services') diff --git a/services/Recorder.qml b/services/Recorder.qml index d5c99ca..e4ce6a8 100644 --- a/services/Recorder.qml +++ b/services/Recorder.qml @@ -2,23 +2,33 @@ pragma Singleton import Quickshell import Quickshell.Io +import QtQuick Singleton { id: root readonly property alias running: props.running readonly property alias paused: props.paused + readonly property alias elapsed: props.elapsed + property bool needsStart + property list startArgs + property bool needsStop + property bool needsPause - function toggle(extraArgs: list): void { - Quickshell.execDetached(["caelestia", "record", ...extraArgs]); - props.running = !props.running; - if (!props.running) - props.paused = false; + function start(extraArgs: list): void { + needsStart = true; + startArgs = extraArgs; + checkProc.running = true; + } + + function stop(): void { + needsStop = true; + checkProc.running = true; } function togglePause(): void { - Quickshell.execDetached(["caelestia", "record", "-p"]); - props.paused = !props.paused; + needsPause = true; + checkProc.running = true; } PersistentProperties { @@ -26,13 +36,47 @@ Singleton { property bool running: false property bool paused: false + property real elapsed: 0 // Might get too large for int reloadableId: "recorder" } Process { + id: checkProc + running: true command: ["pidof", "gpu-screen-recorder"] - onExited: code => props.running = code === 0 + onExited: code => { + props.running = code === 0; + + if (code === 0) { + if (root.needsStop) { + Quickshell.execDetached(["caelestia", "record"]); + props.running = false; + props.paused = false; + } else if (root.needsPause) { + Quickshell.execDetached(["caelestia", "record", "-p"]); + props.paused = !props.paused; + } + } else if (root.needsStart) { + Quickshell.execDetached(["caelestia", "record", ...root.startArgs]); + props.running = true; + props.paused = false; + props.elapsed = 0; + } + + root.needsStart = false; + root.needsStop = false; + root.needsPause = false; + } + } + + Connections { + target: Time + // enabled: props.running && !props.paused + + function onSecondsChanged(): void { + props.elapsed++; + } } } -- cgit v1.2.3-freya