diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-09-15 21:55:10 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-09-15 21:55:10 +1000 |
| commit | 7a9fce9dd417db42d75dc80a86df45ed0402d6d4 (patch) | |
| tree | 1a3671200433275f017073e70e895971bfd94951 /services/Recorder.qml | |
| parent | utilities/record: select mode (diff) | |
| download | caelestia-shell-7a9fce9dd417db42d75dc80a86df45ed0402d6d4.tar.gz caelestia-shell-7a9fce9dd417db42d75dc80a86df45ed0402d6d4.tar.bz2 caelestia-shell-7a9fce9dd417db42d75dc80a86df45ed0402d6d4.zip | |
utilities/record: allow pause/resume recording
Diffstat (limited to '')
| -rw-r--r-- | services/Recorder.qml | 60 |
1 files changed, 52 insertions, 8 deletions
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<string> startArgs + property bool needsStop + property bool needsPause - function toggle(extraArgs: list<string>): void { - Quickshell.execDetached(["caelestia", "record", ...extraArgs]); - props.running = !props.running; - if (!props.running) - props.paused = false; + function start(extraArgs: list<string>): 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++; + } } } |