ScreenRecorder: check for availability
This commit is contained in:
parent
94d64a91b8
commit
3c9ce6f8b5
5 changed files with 107 additions and 28 deletions
|
|
@ -13,6 +13,17 @@ Singleton {
|
|||
property bool isRecording: false
|
||||
property bool isPending: false
|
||||
property string outputPath: ""
|
||||
property bool isAvailable: false
|
||||
|
||||
Component.onCompleted: {
|
||||
checkAvailability()
|
||||
}
|
||||
|
||||
function checkAvailability() {
|
||||
// Detect native or Flatpak gpu-screen-recorder
|
||||
availabilityCheckProcess.command = ["sh", "-c", "command -v gpu-screen-recorder >/dev/null 2>&1 || (command -v flatpak >/dev/null 2>&1 && flatpak list --app | grep -q 'com.dec05eba.gpu_screen_recorder')"]
|
||||
availabilityCheckProcess.running = true
|
||||
}
|
||||
|
||||
// Start or Stop recording
|
||||
function toggleRecording() {
|
||||
|
|
@ -21,6 +32,9 @@ Singleton {
|
|||
|
||||
// Start screen recording using Quickshell.execDetached
|
||||
function startRecording() {
|
||||
if (!isAvailable) {
|
||||
return
|
||||
}
|
||||
if (isRecording || isPending) {
|
||||
return
|
||||
}
|
||||
|
|
@ -88,6 +102,18 @@ Singleton {
|
|||
}
|
||||
}
|
||||
|
||||
// Availability check process
|
||||
Process {
|
||||
id: availabilityCheckProcess
|
||||
command: ["sh", "-c", "true"]
|
||||
onExited: function (exitCode, exitStatus) {
|
||||
// exitCode 0 means available, non-zero means unavailable
|
||||
root.isAvailable = (exitCode === 0)
|
||||
}
|
||||
stdout: StdioCollector {}
|
||||
stderr: StdioCollector {}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: pendingTimer
|
||||
interval: 2000 // Wait 2 seconds to see if process stays alive
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue