Repository navigation
Never overwrite a shell.json the shell could not read #14534
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a399423
Never overwrite a shell.json the shell could not read
omarchybot 22de887
Let the shell finish its startup writes before breaking shell.json
omarchybot bc3336b
Merge quattro, whose Elsewhen panel now saves shell.json after startup
ryanrhughes c20547e
Check the unreadable shell.json guard in the runtime smoke test
ryanrhughes f9490c6
Wait for Elsewhen's first-run save before breaking shell.json
ryanrhughes 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" | ||
|
|
||
| TMPDIR="" | ||
| QS_PID="" | ||
|
|
||
| cleanup() { | ||
| if [[ -n $QS_PID ]] && kill -0 "$QS_PID" 2>/dev/null; then | ||
| kill "$QS_PID" 2>/dev/null || true | ||
| wait "$QS_PID" 2>/dev/null || true | ||
| fi | ||
| [[ -n ${test_root:-} ]] && rm -f "$(shell_ipc_socket "$test_root")" | ||
| [[ -n $TMPDIR && -d $TMPDIR ]] && rm -rf "$TMPDIR" | ||
| return 0 | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| require_compositor "unreadable shell.json test" | ||
| require_command quickshell | ||
| require_command jq | ||
|
|
||
| TMPDIR=$(mktemp -d) | ||
| test_root="$TMPDIR/omarchy" | ||
| test_home="$TMPDIR/home" | ||
| log="$TMPDIR/quickshell.log" | ||
| config="$test_home/.config/omarchy/shell.json" | ||
| mkdir -p "$test_root" "$(dirname "$config")" | ||
| cp -a "$ROOT/shell" "$test_root/shell" | ||
| ln -s "$ROOT/config" "$test_root/config" | ||
| ln -s "$ROOT/bin" "$test_root/bin" | ||
|
|
||
| shell_ipc() { | ||
| OMARCHY_PATH="$test_root" "$ROOT/bin/omarchy-shell" "$@" | ||
| } | ||
|
|
||
| fail_with_log() { | ||
| sed -n '1,200p' "$log" >&2 | ||
| fail "$1" | ||
| } | ||
|
|
||
| # Wait until the running shell reports the bar position given. | ||
| wait_for_position() { | ||
| local position="$1" | ||
| for _ in {1..150}; do | ||
| [[ $(shell_ipc shell listShellConfig 2>/dev/null | jq -r '.bar.position // "top"' 2>/dev/null) == "$position" ]] && return 0 | ||
| kill -0 "$QS_PID" 2>/dev/null || fail_with_log "test shell exited" | ||
| sleep 0.1 | ||
| done | ||
| return 1 | ||
| } | ||
|
|
||
| jq '.bar.position = "bottom"' "$ROOT/config/omarchy/shell.json" >"$config" | ||
|
|
||
| OMARCHY_PATH="$test_root" \ | ||
| HOME="$test_home" \ | ||
| XDG_CONFIG_HOME="$test_home/.config" \ | ||
| XDG_CACHE_HOME="$test_home/.cache" \ | ||
| XDG_STATE_HOME="$test_home/.local/state" \ | ||
| PATH="$ROOT/bin:$PATH" \ | ||
| quickshell -p "$test_root/shell" --no-color >"$log" 2>&1 & | ||
| QS_PID=$! | ||
|
|
||
| wait_for_position bottom || fail_with_log "shell loads the user's shell.json" | ||
|
|
||
| # A hand edit that drops the closing brace. | ||
| sed -i '$ d' "$config" | ||
| cp "$config" "$TMPDIR/broken.json" | ||
| wait_for_position top || fail_with_log "shell falls back to defaults on an unreadable shell.json" | ||
|
|
||
| reply=$(shell_ipc shell setBarWidget omarchy.clock format '"HH:mm"' '{}') || fail_with_log "bar widget setting is accepted" | ||
| [[ $reply == "ok" ]] || fail_with_log "bar widget setting is applied: $reply" | ||
| sleep 1 | ||
| cmp -s "$config" "$TMPDIR/broken.json" || fail "a bar change leaves an unreadable shell.json as the user left it" "$(cat "$config")" | ||
| pass "a bar change leaves an unreadable shell.json as the user left it" | ||
|
|
||
| printf '}\n' >>"$config" | ||
| wait_for_position bottom || fail_with_log "shell picks up shell.json once it is fixed" | ||
|
|
||
| reply=$(shell_ipc shell setBarWidget omarchy.clock format '"H:mm"' '{}') || fail_with_log "bar widget setting is accepted" | ||
| [[ $reply == "ok" ]] || fail_with_log "bar widget setting is applied: $reply" | ||
| saved='.bar.position == "bottom" and any(.bar.layout[][]; .id == "omarchy.clock" and .format == "H:mm")' | ||
| for _ in {1..40}; do | ||
| jq -e "$saved" "$config" >/dev/null 2>&1 && break | ||
| sleep 0.1 | ||
| done | ||
| jq -e "$saved" "$config" >/dev/null || fail "a bar change is saved again once shell.json is fixed" "$(cat "$config")" | ||
| pass "a bar change is saved again once shell.json is fixed" | ||
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.