Repository navigation
Detect and stop Omarchy screen recording via gsr-cli IPC #10397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
calledtoconstruct
wants to merge
10
commits into
omacom:quattro
Choose a base branch
from
calledtoconstruct:fix/screenrecording-pgrep-name
base: quattro
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
aee6cbf
Detect screen recording by process name, not command line
calledtoconstruct bcfc882
Detect Omarchy screen recording via gsr-cli IPC
calledtoconstruct 9669588
Stop screen recording with gsr-cli only
calledtoconstruct 72579f5
Merge quattro into fix/screenrecording-pgrep-name
omarchybot 6bee144
Import Quickshell in the screen recording indicator
omarchybot edb3055
Keep the recording's filename when this stop did not stop it
omarchybot 5ce5cd1
Check -ipc on the recorder's launch line, not anywhere in the file
omarchybot 1b08cfc
Return failure when gsr-cli stop does not stop the recording
calledtoconstruct b7fe0a2
Keep the screen-recording stop test from killing a live webcam
calledtoconstruct ad54208
Assert the stop went to the Omarchy socket
omarchybot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" | ||
|
|
||
| recording="$ROOT/shell/plugins/bar/indicators/ScreenRecording.qml" | ||
| capture="$ROOT/bin/omarchy-capture-screenrecording" | ||
| menu="$ROOT/default/omarchy/omarchy-menu.jsonc" | ||
| socket='${XDG_RUNTIME_DIR:-${XDG_STATE_HOME:-$HOME/.local/state}/omarchy}/omarchy-gsr.sock' | ||
|
|
||
| grep -Fq 'GSR_SOCKET="$RUNTIME_DIR/omarchy-gsr.sock"' "$capture" || | ||
| fail "capture helper uses the shared Omarchy gsr socket" | ||
| grep -Eq '^ *gpu-screen-recorder .*-ipc "\$GSR_SOCKET"' "$capture" || | ||
| fail "gpu-screen-recorder is launched with -ipc on the shared socket" | ||
| grep -Fq 'gsr-cli -ipc "$GSR_SOCKET" status' "$capture" || | ||
| fail "capture helper gates on gsr-cli status for the shared socket" | ||
| grep -Fq 'gsr-cli -ipc "$GSR_SOCKET" stop' "$capture" || | ||
| fail "capture helper stops via gsr-cli on the shared socket" | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| if grep -q 'RECORDING_PID_FILE' "$capture"; then | ||
| fail "stop does not keep a pid file beside gsr-cli" | ||
| fi | ||
| if grep -E 'kill[[:space:]]+(-s[[:space:]]+)?(SIGINT|-INT|-9|-KILL)' "$capture" >/dev/null; then | ||
| fail "stop does not kill the recorder; gsr-cli stop is enough" | ||
| fi | ||
|
|
||
| grep -Fq 'Quickshell.env("XDG_RUNTIME_DIR")' "$recording" || | ||
| fail "indicator builds the gsr socket from XDG_RUNTIME_DIR" | ||
| grep -qx 'import Quickshell' "$recording" || | ||
| fail "indicator imports Quickshell, which Quickshell.env needs" | ||
| grep -Fq '"gsr-cli", "-ipc"' "$recording" || | ||
| fail "indicator status uses gsr-cli -ipc" | ||
| grep -Fq '"status"' "$recording" || | ||
| fail "indicator status asks gsr-cli for status" | ||
| grep -Fq '/omarchy-gsr.sock' "$recording" || | ||
| fail "indicator uses the shared Omarchy gsr socket" | ||
|
|
||
| grep -Fq "gsr-cli -ipc \\\"$socket\\\" status" "$menu" || | ||
| fail "the capture menu uses gsr-cli status on the shared socket" | ||
|
|
||
| for file in "$capture" "$recording" "$menu"; do | ||
| if grep -E 'pidof[[:space:]"]+-q[[:space:]"]+gpu-screen-recorder|pgrep[[:space:]"-]+-f[[:space:]"]+\^?gpu-screen-recorder' "$file" >/dev/null; then | ||
| fail "screen-recording gate does not use pidof or pgrep -f for gpu-screen-recorder" "$file" | ||
| fi | ||
| done | ||
|
|
||
| if grep -E 'pkill[[:space:]].*-f[[:space:]"]+\^?gpu-screen-recorder' "$capture" >/dev/null; then | ||
| fail "stop does not pkill -f gpu-screen-recorder" | ||
| fi | ||
| if grep -E 'pgrep[[:space:]].*-f[[:space:]"]+\^?gpu-screen-recorder' "$capture" >/dev/null; then | ||
| fail "stop does not pgrep -f gpu-screen-recorder" | ||
| fi | ||
|
|
||
| pass "screen recording start/status/stop talk to the Omarchy gsr socket" | ||
|
|
||
| # Run the stop path. A stub that exits 0 for the notification must not hide a | ||
| # failed gsr-cli stop, and a successful stop must still print and forget the file. | ||
| stub_bin=$(mktemp -d) | ||
| runtime=$(mktemp -d) | ||
| videos=$(mktemp -d) | ||
| trap 'rm -rf "$stub_bin" "$runtime" "$videos"' EXIT | ||
|
|
||
| cat >"$stub_bin/gsr-cli" <<'SH' | ||
| #!/bin/bash | ||
| printf '%s\n' "$*" >>"${GSR_LOG:?}" | ||
| if [[ $1 == -ipc && $3 == status ]]; then | ||
| exit 0 | ||
| fi | ||
| if [[ $1 == -ipc && $3 == stop ]]; then | ||
| exit "${GSR_STOP_STATUS:-0}" | ||
| fi | ||
| exit 1 | ||
| SH | ||
| cat >"$stub_bin/omarchy-notification-send" <<'SH' | ||
| #!/bin/bash | ||
| printf '%s\n' "$*" >>"${NOTE_LOG:?}" | ||
| exit 0 | ||
| SH | ||
| cat >"$stub_bin/omarchy-shell" <<'SH' | ||
| #!/bin/bash | ||
| exit 0 | ||
| SH | ||
| cat >"$stub_bin/ffprobe" <<'SH' | ||
| #!/bin/bash | ||
| exit 1 | ||
| SH | ||
| cat >"$stub_bin/ffmpeg" <<'SH' | ||
| #!/bin/bash | ||
| exit 1 | ||
| SH | ||
| cat >"$stub_bin/pkill" <<'SH' | ||
| #!/bin/bash | ||
| printf '%s\n' "$*" >>"${PKILL_LOG:?}" | ||
| exit 0 | ||
| SH | ||
| chmod +x "$stub_bin"/* | ||
|
|
||
| export PATH="$stub_bin:$PATH" | ||
| export GSR_LOG="$videos/gsr.log" | ||
| export NOTE_LOG="$videos/note.log" | ||
| export PKILL_LOG="$videos/pkill.log" | ||
| export XDG_RUNTIME_DIR="$runtime" | ||
| export OMARCHY_SCREENRECORD_DIR="$videos" | ||
|
|
||
| clip="$videos/clip.mp4" | ||
| printf 'not a video\n' >"$clip" | ||
| printf '%s\n' "$clip" >"$runtime/omarchy-screenrecord-filename" | ||
|
|
||
| set +e | ||
| GSR_STOP_STATUS=1 "$capture" --stop-recording >/dev/null 2>&1 | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| failed_status=$? | ||
| set -e | ||
| [[ $failed_status -ne 0 ]] || | ||
| fail "a failed gsr-cli stop does not exit successfully" "status $failed_status" | ||
| [[ -f $runtime/omarchy-screenrecord-filename ]] || | ||
| fail "a failed gsr-cli stop keeps the recording filename" | ||
| grep -Fq 'Could not stop the recording through gsr-cli.' "$NOTE_LOG" || | ||
| fail "a failed gsr-cli stop reports the error" "$(cat "$NOTE_LOG")" | ||
| pass "a failed gsr-cli stop exits non-zero and keeps the filename" | ||
|
|
||
| : >"$GSR_LOG" | ||
| : >"$NOTE_LOG" | ||
| printf '%s\n' "$clip" >"$runtime/omarchy-screenrecord-filename" | ||
| saved=$("$capture" --stop-recording) | ||
| [[ $saved == "$clip" ]] || | ||
| fail "a successful stop prints the saved recording" "$saved" | ||
| [[ ! -e $runtime/omarchy-screenrecord-filename ]] || | ||
| fail "a successful stop removes the recording filename" | ||
| grep -Fqx -- "-ipc $runtime/omarchy-gsr.sock stop" "$GSR_LOG" || | ||
| fail "a successful stop calls gsr-cli stop on the Omarchy gsr socket" "$(cat "$GSR_LOG")" | ||
| pass "a successful gsr-cli stop prints the recording and clears its filename" | ||
|
|
||
| grep -Fq -- '-f WebcamOverlay' "$videos/pkill.log" || | ||
| fail "stop cleanup does not call the stubbed pkill" "$(cat "$videos/pkill.log" 2>/dev/null || true)" | ||
| pass "stop cleanup calls the stubbed pkill instead of a live WebcamOverlay" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.