Fix record button
This commit is contained in:
parent
5c29a6086a
commit
2ada1d4532
1 changed files with 17 additions and 36 deletions
|
|
@ -298,11 +298,11 @@ PanelWithOverlay {
|
||||||
isRecording: sidebarPopupRect.isRecording
|
isRecording: sidebarPopupRect.isRecording
|
||||||
|
|
||||||
onRecordingRequested: {
|
onRecordingRequested: {
|
||||||
startRecording();
|
sidebarPopupRect.startRecording();
|
||||||
}
|
}
|
||||||
|
|
||||||
onStopRecordingRequested: {
|
onStopRecordingRequested: {
|
||||||
stopRecording();
|
sidebarPopupRect.stopRecording();
|
||||||
}
|
}
|
||||||
|
|
||||||
onRecordingStateMismatch: function (actualState) {
|
onRecordingStateMismatch: function (actualState) {
|
||||||
|
|
@ -323,10 +323,8 @@ PanelWithOverlay {
|
||||||
|
|
||||||
// Recording properties
|
// Recording properties
|
||||||
property bool isRecording: false
|
property bool isRecording: false
|
||||||
property var recordingProcess: null
|
|
||||||
property var recordingPid: null
|
|
||||||
|
|
||||||
// Start screen recording
|
// Start screen recording using Quickshell.execDetached
|
||||||
function startRecording() {
|
function startRecording() {
|
||||||
var currentDate = new Date();
|
var currentDate = new Date();
|
||||||
var hours = String(currentDate.getHours()).padStart(2, '0');
|
var hours = String(currentDate.getHours()).padStart(2, '0');
|
||||||
|
|
@ -336,40 +334,28 @@ PanelWithOverlay {
|
||||||
var year = currentDate.getFullYear();
|
var year = currentDate.getFullYear();
|
||||||
|
|
||||||
var filename = hours + "-" + minutes + "-" + day + "-" + month + "-" + year + ".mp4";
|
var filename = hours + "-" + minutes + "-" + day + "-" + month + "-" + year + ".mp4";
|
||||||
var outputPath = Settings.settings.videoPath + filename;
|
var videoPath = Settings.settings.videoPath;
|
||||||
|
if (videoPath && !videoPath.endsWith("/")) {
|
||||||
|
videoPath += "/";
|
||||||
|
}
|
||||||
|
var outputPath = videoPath + filename;
|
||||||
var command = "gpu-screen-recorder -w portal -f 60 -a default_output -o " + outputPath;
|
var command = "gpu-screen-recorder -w portal -f 60 -a default_output -o " + outputPath;
|
||||||
var qmlString = 'import Quickshell.Io; Process { command: ["sh", "-c", "' + command + '"]; running: true }';
|
Quickshell.execDetached(["sh", "-c", command]);
|
||||||
|
|
||||||
recordingProcess = Qt.createQmlObject(qmlString, sidebarPopup);
|
|
||||||
isRecording = true;
|
isRecording = true;
|
||||||
quickAccessWidget.isRecording = true;
|
quickAccessWidget.isRecording = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop recording with cleanup
|
// Stop recording using Quickshell.execDetached
|
||||||
function stopRecording() {
|
function stopRecording() {
|
||||||
if (recordingProcess && isRecording) {
|
Quickshell.execDetached(["sh", "-c", "pkill -SIGINT -f 'gpu-screen-recorder.*portal'"]);
|
||||||
var stopQmlString = 'import Quickshell.Io; Process { command: ["sh", "-c", "pkill -SIGINT -f \'gpu-screen-recorder.*portal\'"]; running: true; onExited: function() { destroy() } }';
|
// Optionally, force kill after a delay
|
||||||
|
var cleanupTimer = Qt.createQmlObject('import QtQuick; Timer { interval: 3000; running: true; repeat: false }', sidebarPopupRect);
|
||||||
var stopProcess = Qt.createQmlObject(stopQmlString, sidebarPopup);
|
|
||||||
|
|
||||||
var cleanupTimer = Qt.createQmlObject('import QtQuick; Timer { interval: 3000; running: true; repeat: false }', sidebarPopup);
|
|
||||||
cleanupTimer.triggered.connect(function () {
|
cleanupTimer.triggered.connect(function () {
|
||||||
if (recordingProcess) {
|
Quickshell.execDetached(["sh", "-c", "pkill -9 -f 'gpu-screen-recorder.*portal' 2>/dev/null || true"]);
|
||||||
recordingProcess.running = false;
|
|
||||||
recordingProcess.destroy();
|
|
||||||
recordingProcess = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var forceKillQml = 'import Quickshell.Io; Process { command: ["sh", "-c", "pkill -9 -f \'gpu-screen-recorder.*portal\' 2>/dev/null || true"]; running: true; onExited: function() { destroy() } }';
|
|
||||||
var forceKillProcess = Qt.createQmlObject(forceKillQml, sidebarPopup);
|
|
||||||
|
|
||||||
cleanupTimer.destroy();
|
cleanupTimer.destroy();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
isRecording = false;
|
isRecording = false;
|
||||||
quickAccessWidget.isRecording = false;
|
quickAccessWidget.isRecording = false;
|
||||||
recordingPid = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up processes on destruction
|
// Clean up processes on destruction
|
||||||
|
|
@ -377,11 +363,6 @@ PanelWithOverlay {
|
||||||
if (isRecording) {
|
if (isRecording) {
|
||||||
stopRecording();
|
stopRecording();
|
||||||
}
|
}
|
||||||
if (recordingProcess) {
|
|
||||||
recordingProcess.running = false;
|
|
||||||
recordingProcess.destroy();
|
|
||||||
recordingProcess = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Corners {
|
Corners {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue