diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2026-04-25 15:24:42 +0200 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2026-04-25 15:24:42 +0200 |
| commit | 20577d184c030a23a6b384b8570f583bb32f14d2 (patch) | |
| tree | bfb7fc21d27f31218b838ede80795f525b1952fd /accounts/gkleen@sif/shell/quickshell | |
| parent | 395ca23e9599460cdfa91c34ae52296edf7cfd41 (diff) | |
| download | nixos-20577d184c030a23a6b384b8570f583bb32f14d2.tar nixos-20577d184c030a23a6b384b8570f583bb32f14d2.tar.gz nixos-20577d184c030a23a6b384b8570f583bb32f14d2.tar.bz2 nixos-20577d184c030a23a6b384b8570f583bb32f14d2.tar.xz nixos-20577d184c030a23a6b384b8570f583bb32f14d2.zip | |
wf-recorderflakes
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell')
| -rw-r--r-- | accounts/gkleen@sif/shell/quickshell/Services/ScreenRecord.qml | 63 | ||||
| -rw-r--r-- | accounts/gkleen@sif/shell/quickshell/UnixIPC.qml | 9 |
2 files changed, 72 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/Services/ScreenRecord.qml b/accounts/gkleen@sif/shell/quickshell/Services/ScreenRecord.qml new file mode 100644 index 00000000..eb415452 --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/Services/ScreenRecord.qml | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | pragma Singleton | ||
| 2 | |||
| 3 | import Quickshell | ||
| 4 | import Quickshell.Io | ||
| 5 | |||
| 6 | Singleton { | ||
| 7 | id: root | ||
| 8 | property bool active: false | ||
| 9 | property bool slurpSuccess: false | ||
| 10 | |||
| 11 | onActiveChanged: { | ||
| 12 | if (!active) { | ||
| 13 | slurp.running = false; | ||
| 14 | screenRecorder.running = false; | ||
| 15 | } | ||
| 16 | if (active) | ||
| 17 | slurp.running = true; | ||
| 18 | } | ||
| 19 | |||
| 20 | Process { | ||
| 21 | id: screenRecorder | ||
| 22 | running: false | ||
| 23 | onRunningChanged: { | ||
| 24 | console.log("wf-recorder running: ", screenRecorder.running); | ||
| 25 | |||
| 26 | if (!screenRecorder.running && !slurp.running) | ||
| 27 | root.active = false; | ||
| 28 | } | ||
| 29 | stderr: SplitParser { | ||
| 30 | onRead: line => console.log("wf-recorder stderr: ", line) | ||
| 31 | } | ||
| 32 | stdout: SplitParser { | ||
| 33 | onRead: line => console.log("wf-recorder stdout: ", line) | ||
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 37 | Process { | ||
| 38 | id: slurp | ||
| 39 | running: false | ||
| 40 | command: [ @slurp@, "-o", "-d" ] | ||
| 41 | stdout: StdioCollector {} | ||
| 42 | stderr: SplitParser { | ||
| 43 | onRead: line => console.log("slurp stderr: ", line) | ||
| 44 | } | ||
| 45 | onExited: exitCode => { | ||
| 46 | if (exitCode !== 0) { | ||
| 47 | console.log("slurp failed: ", exitCode); | ||
| 48 | root.active = false; | ||
| 49 | return; | ||
| 50 | } | ||
| 51 | console.log("slurp succeeded: ", slurp.stdout.text); | ||
| 52 | |||
| 53 | const nowDate = new Date(); | ||
| 54 | |||
| 55 | screenRecorder.command = [ | ||
| 56 | @wf-recorder@, | ||
| 57 | "-g", slurp.stdout.text, | ||
| 58 | "-f", `${Quickshell.env("HOME")}/screenshots/${nowDate.toLocaleString(Qt.locale(), "yyyy-MM-ddThh:mm:ss")}.mkv`, | ||
| 59 | ]; | ||
| 60 | screenRecorder.running = true; | ||
| 61 | } | ||
| 62 | } | ||
| 63 | } | ||
diff --git a/accounts/gkleen@sif/shell/quickshell/UnixIPC.qml b/accounts/gkleen@sif/shell/quickshell/UnixIPC.qml index 05a40dbc..3d950031 100644 --- a/accounts/gkleen@sif/shell/quickshell/UnixIPC.qml +++ b/accounts/gkleen@sif/shell/quickshell/UnixIPC.qml | |||
| @@ -39,6 +39,8 @@ Scope { | |||
| 39 | root.onCommandMpris(command.Mpris); | 39 | root.onCommandMpris(command.Mpris); |
| 40 | else if (command.Notifications) | 40 | else if (command.Notifications) |
| 41 | root.onCommandNotifications(command.Notifications); | 41 | root.onCommandNotifications(command.Notifications); |
| 42 | else if (command.ScreenRecord) | ||
| 43 | root.onCommandScreenRecord(command.ScreenRecord); | ||
| 42 | else | 44 | else |
| 43 | console.warn("UnixIPC: Command not handled:", JSON.stringify(command)); | 45 | console.warn("UnixIPC: Command not handled:", JSON.stringify(command)); |
| 44 | } | 46 | } |
| @@ -94,4 +96,11 @@ Scope { | |||
| 94 | notif.dismiss(); | 96 | notif.dismiss(); |
| 95 | } | 97 | } |
| 96 | } | 98 | } |
| 99 | |||
| 100 | function onCommandScreenRecord(command) { | ||
| 101 | if (command.Toggle) | ||
| 102 | ScreenRecord.active = !ScreenRecord.active; | ||
| 103 | else | ||
| 104 | console.warn("UnixIPC.ScreenRecord: Command not handled:", JSON.stringify(command)); | ||
| 105 | } | ||
| 97 | } | 106 | } |
