Added issue templates and fixed screenRecorder status symbol

ScreenRecorder: add proper checks for screenRecorder
ISSUE_TEMPLATE: add bug_report and feature_request
This commit is contained in:
Ly-sec 2025-08-27 13:21:53 +02:00
parent ae0228dc25
commit 6f7528c87a
4 changed files with 129 additions and 13 deletions

View file

@ -1,7 +1,7 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
import qs.Commons
import qs.Services
@ -10,19 +10,20 @@ Singleton {
readonly property var settings: Settings.data.screenRecorder
property bool isRecording: false
property bool isPending: false
property string outputPath: ""
// Start or Stop recording
function toggleRecording() {
isRecording ? stopRecording() : startRecording()
(isRecording || isPending) ? stopRecording() : startRecording()
}
// Start screen recording using Quickshell.execDetached
function startRecording() {
if (isRecording) {
if (isRecording || isPending) {
return
}
isRecording = true
isPending = true
var filename = Time.getFormattedTimestamp() + ".mp4"
var videoDir = settings.directory
@ -43,23 +44,78 @@ Singleton {
notify-send "gpu-screen-recorder not installed!" -u critical
fi`
//Logger.log("ScreenRecorder", command)
Quickshell.execDetached(["sh", "-c", command])
Logger.log("ScreenRecorder", "Started recording")
// Use Process instead of execDetached so we can monitor it
recorderProcess.exec({
command: ["sh", "-c", command]
})
// Start monitoring - if process ends quickly, it was likely cancelled
pendingTimer.running = true
}
// Stop recording using Quickshell.execDetached
function stopRecording() {
if (!isRecording) {
if (!isRecording && !isPending) {
return
}
Quickshell.execDetached(["sh", "-c", "pkill -SIGINT -f 'gpu-screen-recorder'"])
Logger.log("ScreenRecorder", "Finished recording:", outputPath)
Quickshell.execDetached(["sh", "-c", "pkill -SIGINT -f 'gpu-screen-recorder' || pkill -SIGINT -f 'com.dec05eba.gpu_screen_recorder'"])
isRecording = false
isPending = false
pendingTimer.running = false
monitorTimer.running = false
// Just in case, force kill after 3 seconds
killTimer.running = true
isRecording = false
}
// Process to run and monitor gpu-screen-recorder
Process {
id: recorderProcess
onExited: function(exitCode, exitStatus) {
if (isPending) {
// Process ended while we were pending - likely cancelled or error
isPending = false
pendingTimer.running = false
} else if (isRecording) {
// Process ended normally while recording
isRecording = false
monitorTimer.running = false
}
}
}
Timer {
id: pendingTimer
interval: 2000 // Wait 2 seconds to see if process stays alive
running: false
repeat: false
onTriggered: {
if (isPending && recorderProcess.running) {
// Process is still running after 2 seconds - assume recording started successfully
isPending = false
isRecording = true
monitorTimer.running = true
} else if (isPending) {
// Process not running anymore - was cancelled or failed
isPending = false
}
}
}
// Monitor timer to periodically check if we're still recording
Timer {
id: monitorTimer
interval: 2000
running: false
repeat: true
onTriggered: {
if (!recorderProcess.running && isRecording) {
isRecording = false
running = false
}
}
}
Timer {
@ -68,7 +124,7 @@ Singleton {
running: false
repeat: false
onTriggered: {
Quickshell.execDetached(["sh", "-c", "pkill -9 -f 'gpu-screen-recorder' 2>/dev/null || true"])
Quickshell.execDetached(["sh", "-c", "pkill -9 -f 'gpu-screen-recorder' 2>/dev/null || pkill -9 -f 'com.dec05eba.gpu_screen_recorder' 2>/dev/null || true"])
}
}
}
}