Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions bin/omarchy-capture-screenrecording
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ small | medium | large) ;;
esac

# --status only answers whether our recording runs, for the bar and the menu, so
# it needs no recordings directory and never notifies.
if [[ $STATUS != "true" && ! -d $OUTPUT_DIR ]]; then
# it needs no recordings directory and never notifies. A stop must reach the
# recorder too: the directory only names new recordings, and refusing a stop
# would leave a recording with nowhere to write unstoppable.
if [[ $STATUS != "true" && $STOP_RECORDING != "true" && ! -d $OUTPUT_DIR ]]; then
omarchy-notification-send -u critical -t 3000 "$(omarchy-i18n capture.noRecordingDir "$OUTPUT_DIR")"
exit 1
fi
Expand Down
33 changes: 33 additions & 0 deletions test/shell.d/screenrecording-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,39 @@ grep -Fxq -- '--signal INT' "$helper_calls" ||
fail "stop announces no saved recording when none was recorded as started" "$(<"$OMARCHY_TEST_NOTIFICATION_ARGS")"
pass "without a saved pid, status and stop select the user's recorders"

# A stop has to reach the recorder even when the recordings directory is gone
# (renamed, unmounted): the directory only names new recordings, and the stop
# reads its path back from the runtime state file. Starting still refuses, so
# a start cannot fill a directory the user moved away.
stop_runtime="$tmp_dir/stop-missing-dir-runtime"
mkdir -p "$stop_runtime"
touch "$recording_flag"
: >"$helper_calls"
rm -f "$OMARCHY_TEST_NOTIFICATION_ARGS"
XDG_RUNTIME_DIR="$stop_runtime" OMARCHY_TEST_HELPER_CALLS="$helper_calls" OMARCHY_TEST_RECORDING="$recording_flag" \
OMARCHY_SCREENRECORD_DIR="$tmp_dir/no-such-recordings" \
"$ROOT/bin/omarchy-capture-screenrecording" --stop-recording >/dev/null 2>&1 ||
fail "stop reaches the recorder without a recordings directory" "$(cat "$helper_calls" 2>/dev/null)"
grep -Fxq -- '--signal INT' "$helper_calls" ||
fail "stop signals the active recorder when the recordings directory is missing" "$(cat "$helper_calls")"
[[ ! -e $recording_flag ]] || fail "the recording ends when stop runs without a recordings directory"
[[ ! -e $OMARCHY_TEST_NOTIFICATION_ARGS ]] ||
fail "stop does not report a missing recordings directory while a recording runs" "$(cat "$OMARCHY_TEST_NOTIFICATION_ARGS")"
[[ ! -e $stop_runtime/omarchy-screenrecord-filename && ! -e $stop_runtime/omarchy-screenrecord-pid ]] ||
fail "stop clears its state files without a recordings directory" "$(ls -a "$stop_runtime")"
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
pass "stop ends a recording without a recordings directory"

: >"$helper_calls"
rm -f "$OMARCHY_TEST_NOTIFICATION_ARGS"
if XDG_RUNTIME_DIR="$stop_runtime" OMARCHY_TEST_HELPER_CALLS="$helper_calls" OMARCHY_TEST_RECORDING="$recording_flag" \
OMARCHY_SCREENRECORD_DIR="$tmp_dir/no-such-recordings" \
"$ROOT/bin/omarchy-capture-screenrecording" --fullscreen >/dev/null 2>&1; then
fail "starting still refuses a missing recordings directory"
fi
[[ -s $OMARCHY_TEST_NOTIFICATION_ARGS ]] || fail "starting a recording without a recordings directory is named to the user"
[[ ! -s $helper_calls ]] || fail "starting never reaches a recorder when the recordings directory is missing" "$(cat "$helper_calls")"
pass "starting still refuses a missing recordings directory"

# The bar indicator and the menu's Stop row ask --status, so they show a stop
# exactly when the toggle has a recording of ours to end. It needs no
# recordings directory, never notifies and never signals.
Expand Down
Loading