Skip to content

Commit ddd43c8

Browse files
committed
refactor: remove CopyBox component and update recording logic to use detached processes
1 parent 89b319a commit ddd43c8

3 files changed

Lines changed: 21 additions & 165 deletions

File tree

CaptureToolbar.qml

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ PluginComponent {
4545
property bool isMicCaptured: false
4646
property bool isMicMuted: false
4747
property int recordingElapsed: 0
48-
property int recordingPid: 0
48+
property var recordingProcess: null
4949
property bool showRecPill: (pluginData && pluginData.showRecPill !== undefined) ? pluginData.showRecPill : true
5050
property bool showNotify: (pluginData && pluginData.showNotify !== undefined) ? pluginData.showNotify : true
5151
property bool enableEditorShortcut: (pluginData && pluginData.enableEditorShortcut != null) ? pluginData.enableEditorShortcut : true
@@ -540,6 +540,22 @@ PluginComponent {
540540
"else " +
541541
"start_rec; exec gpu-screen-recorder -w portal" + gsrSuffix + "; " +
542542
"fi";
543+
} else if (root.captureMode === "all") {
544+
scriptBody = "sleep 0.2; mkdir -p \"" + dir + "\"; " +
545+
"HAS_PORTAL=\"\"; " +
546+
"if command -v dbus-send >/dev/null 2>&1; then " +
547+
"dbus-send --dest=org.freedesktop.portal.Desktop --print-reply /org/freedesktop/portal/desktop org.freedesktop.DBus.Introspectable.Introspect 2>/dev/null | grep -q \"org.freedesktop.portal.ScreenCast\" && HAS_PORTAL=\"1\"; " +
548+
"elif command -v busctl >/dev/null 2>&1; then " +
549+
"busctl introspect org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop 2>/dev/null | grep -q \"org.freedesktop.portal.ScreenCast\" && HAS_PORTAL=\"1\"; " +
550+
"fi; " +
551+
"if [ -n \"$HAS_PORTAL\" ] && { [ \"$XDG_SESSION_TYPE\" = \"wayland\" ] || [ -n \"$WAYLAND_DISPLAY\" ]; }; then " +
552+
"exec gpu-screen-recorder -w portal" + gsrSuffix + "; " +
553+
"elif [ \"$XDG_SESSION_TYPE\" = \"wayland\" ] || [ -n \"$WAYLAND_DISPLAY\" ]; then " +
554+
"notify-send \"Multi-Monitor Recording\" \"Recording focused screen. Install a desktop portal (e.g. xdg-desktop-portal-niri) to record all screens on Wayland.\" -t 5000; " +
555+
"exec gpu-screen-recorder -w \"$MONITOR\"" + gsrSuffix + "; " +
556+
"else " +
557+
"exec gpu-screen-recorder -w screen" + gsrSuffix + "; " +
558+
"fi";
543559
} else {
544560
scriptBody = "sleep 0.2; mkdir -p \"" + dir + "\"; exec gpu-screen-recorder -w \"$MONITOR\"" + gsrSuffix;
545561
}
@@ -554,48 +570,34 @@ PluginComponent {
554570
}
555571
root.close();
556572

557-
recorderProcess.command = ["bash", "-c", finalCmd];
558-
recorderProcess.running = true;
573+
Quickshell.execDetached(["bash", "-c", finalCmd]);
559574

560575
if (root.showNotify && !deferRecordingUi) {
561576
Quickshell.execDetached(["notify-send", "Recording Started", "Saving to " + dir]);
562577
}
563578
}
564579

565580
function stopRecording() {
566-
if (root.recordingPid > 0) {
567-
Quickshell.execDetached(["kill", "-SIGINT", String(root.recordingPid)]);
568-
} else {
569-
Quickshell.execDetached(["pkill", "-SIGINT", "-f", "gpu-screen-recorder"]);
570-
}
581+
Quickshell.execDetached(["pkill", "-SIGINT", "-f", "gpu-screen-recorder"]);
571582
Quickshell.execDetached(["pactl", "set-source-mute", "@DEFAULT_SOURCE@", "0"]);
572583
root.isRecording = false;
573584
root.isPaused = false;
574585
root.isMicCaptured = false;
575586
root.isMicMuted = false;
576587
root.recordingElapsed = 0;
577-
root.recordingPid = 0;
578588

579589
if (root.showNotify) {
580590
Quickshell.execDetached(["notify-send", "Recording Stopped", "Video saved to " + (root.videoCustomPath || "~/Videos")]);
581591
}
582592
}
583593

584594
function pauseRecording() {
585-
if (root.recordingPid > 0) {
586-
Quickshell.execDetached(["kill", "-SIGUSR2", String(root.recordingPid)]);
587-
} else {
588-
Quickshell.execDetached(["pkill", "-SIGUSR2", "-f", "gpu-screen-recorder"]);
589-
}
595+
Quickshell.execDetached(["pkill", "-SIGUSR2", "-f", "gpu-screen-recorder"]);
590596
root.isPaused = true;
591597
}
592598

593599
function resumeRecording() {
594-
if (root.recordingPid > 0) {
595-
Quickshell.execDetached(["kill", "-SIGUSR2", String(root.recordingPid)]);
596-
} else {
597-
Quickshell.execDetached(["pkill", "-SIGUSR2", "-f", "gpu-screen-recorder"]);
598-
}
600+
Quickshell.execDetached(["pkill", "-SIGUSR2", "-f", "gpu-screen-recorder"]);
599601
root.isPaused = false;
600602
}
601603

@@ -607,23 +609,6 @@ PluginComponent {
607609
return (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s;
608610
}
609611

610-
Process {
611-
id: recorderProcess
612-
command: []
613-
running: false
614-
onStarted: {
615-
root.recordingPid = processId;
616-
}
617-
onExited: exitCode => {
618-
root.isRecording = false;
619-
root.isPaused = false;
620-
root.isMicCaptured = false;
621-
root.isMicMuted = false;
622-
root.recordingElapsed = 0;
623-
root.recordingPid = 0;
624-
}
625-
}
626-
627612
// Recording elapsed timer
628613
Timer {
629614
id: recordingTimer

CopyBox.qml

Lines changed: 0 additions & 58 deletions
This file was deleted.

Settings.qml

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -519,76 +519,5 @@ PluginSettings {
519519
}
520520
}
521521
}
522-
523-
// --- Commands & Shortcuts ---
524-
Rectangle {
525-
width: parent.width
526-
height: commandsGroup.implicitHeight + Theme.spacingM * 2
527-
color: Theme.surfaceContainer
528-
radius: Theme.cornerRadius
529-
border.color: Theme.outline
530-
border.width: 1
531-
opacity: 0.8
532-
533-
Column {
534-
id: commandsGroup
535-
anchors.fill: parent
536-
anchors.margins: Theme.spacingM
537-
spacing: Theme.spacingM
538-
539-
Row {
540-
width: parent.width; spacing: Theme.spacingM
541-
DankIcon { name: "terminal"; size: 22; anchors.verticalCenter: parent.verticalCenter; opacity: 0.8 }
542-
StyledText {
543-
text: "Commands & Shortcuts"
544-
font.pixelSize: Theme.fontSizeMedium
545-
font.weight: Font.Medium
546-
color: Theme.surfaceText
547-
anchors.verticalCenter: parent.verticalCenter
548-
}
549-
}
550-
551-
StyledText {
552-
width: parent.width
553-
text: "You can open, close, or toggle the screen capture toolbar using the dms CLI:"
554-
font.pixelSize: Theme.fontSizeSmall
555-
color: Theme.surfaceVariantText
556-
wrapMode: Text.WordWrap
557-
}
558-
559-
CopyBox {
560-
width: parent.width
561-
label: "Toggle Toolbar Command"
562-
text: "dms ipc call screenCaptureToolbar toggle"
563-
}
564-
565-
CopyBox {
566-
width: parent.width
567-
label: "Open Toolbar Command"
568-
text: "dms ipc call screenCaptureToolbar open"
569-
}
570-
571-
CopyBox {
572-
width: parent.width
573-
label: "Close Toolbar Command"
574-
text: "dms ipc call screenCaptureToolbar close"
575-
}
576-
577-
StyledText {
578-
width: parent.width
579-
text: "To trigger the screen capture toolbar using the Print key, add this spawn command to your Niri configuration binds:"
580-
font.pixelSize: Theme.fontSizeSmall
581-
color: Theme.primary
582-
font.italic: true
583-
wrapMode: Text.WordWrap
584-
}
585-
586-
CopyBox {
587-
width: parent.width
588-
label: "Niri Bind Configuration"
589-
text: "Print { spawn \"dms\" \"ipc\" \"call\" \"screenCaptureToolbar\" \"toggle\"; }"
590-
}
591-
}
592-
}
593522
}
594523
}

0 commit comments

Comments
 (0)