diff --git a/bin/omarchy-channel-current b/bin/omarchy-channel-current index 5575b1b9..27f25bcb 100755 --- a/bin/omarchy-channel-current +++ b/bin/omarchy-channel-current @@ -12,22 +12,26 @@ if [[ -r $conf ]]; then [[ -n $configured_path ]] && omarchy_path="$configured_path" fi -channel=$(omarchy-version-channel 2>/dev/null | awk '{ print $1 }') +# Dev is a linked source checkout: OMARCHY_PATH points somewhere other than +# the package-backed install at /usr/share/omarchy. This takes precedence over +# the package channels, since the checkout overrides whatever is installed. +if [[ $omarchy_path != "/usr/share/omarchy" ]]; then + echo dev + exit 0 +fi +# omarchy-dev / omarchy-settings-dev are only shipped from the edge mirror, so +# their presence alone means edge. omarchy / omarchy-settings come from either +# the stable or rc mirror, distinguished by omarchy-version-channel. if pacman -Q omarchy-dev omarchy-settings-dev >/dev/null 2>&1; then + echo edge +elif pacman -Q omarchy omarchy-settings >/dev/null 2>&1; then + channel=$(omarchy-version-channel 2>/dev/null | awk '{ print $1 }') case "$channel" in + stable) echo stable ;; rc) echo rc ;; - edge) - if [[ $omarchy_path == "/usr/share/omarchy" ]]; then - echo dev - else - echo edge - fi - ;; *) echo unknown ;; esac -elif pacman -Q omarchy omarchy-settings >/dev/null 2>&1 && [[ $channel == "stable" ]]; then - echo stable else echo unknown fi diff --git a/bin/omarchy-channel-set b/bin/omarchy-channel-set index aeec0d85..704fb7ba 100755 --- a/bin/omarchy-channel-set +++ b/bin/omarchy-channel-set @@ -1,18 +1,18 @@ #!/bin/bash # omarchy:summary=Set the Omarchy package channel. -# omarchy:args= +# omarchy:args= # omarchy:requires-sudo=true set -euo pipefail -usage() { echo "Usage: omarchy-channel-set [stable|rc|dev|edge]"; } +usage() { echo "Usage: omarchy-channel-set [stable|rc|edge|dev]"; } fail() { echo "Error: $*" >&2; exit 1; } -confirm_edge() { +confirm_dev() { cat <<'WARNING' -Edge links Omarchy directly to a mutable source checkout. +Dev links Omarchy directly to a mutable source checkout. This disables package-based protections for the Omarchy code path, including normal package updates and package-backed snapshot restores. You'll be @@ -20,15 +20,15 @@ responsible for pulling, fixing, and restoring that checkout yourself. WARNING - gum confirm --default=false "Enable Edge anyway?" + gum confirm --default=false "Enable Dev anyway?" } -choose_edge_checkout() { +choose_dev_checkout() { local default_path="$HOME/Work/omarchy" - local path="${OMARCHY_EDGE_PATH:-}" + local path="${OMARCHY_DEV_PATH:-}" if [[ -z $path ]]; then - path=$(gum input --value "$default_path" --placeholder "$default_path" --header "Where should Edge checkout live? Existing non-checkout paths will not be overwritten.") || exit 1 + path=$(gum input --value "$default_path" --placeholder "$default_path" --header "Where should Dev checkout live? Existing non-checkout paths will not be overwritten.") || exit 1 fi path="${path:-$default_path}" @@ -50,11 +50,11 @@ choose_edge_checkout() { printf '%s\n' "$path" } -sync_edge_checkout() { +sync_dev_checkout() { local checkout="$1" if [[ -d $checkout/.git ]]; then - echo "Updating Edge checkout at $checkout" + echo "Updating Dev checkout at $checkout" git -C "$checkout" fetch origin quattro git -C "$checkout" checkout quattro 2>/dev/null || git -C "$checkout" checkout --track origin/quattro git -C "$checkout" pull --ff-only origin quattro @@ -68,7 +68,7 @@ sync_edge_checkout() { (( $# > 0 )) || { usage; exit 1; } -edge_checkout="" +dev_checkout="" channel="$1" case "$channel" in @@ -78,15 +78,15 @@ case "$channel" in ;; rc) pacman_channel=rc - packages=(omarchy-dev omarchy-settings-dev) + packages=(omarchy omarchy-settings) ;; - dev) + edge) pacman_channel=edge packages=(omarchy-dev omarchy-settings-dev) ;; - edge|source) - confirm_edge || { echo "Cancelled."; exit 0; } - edge_checkout=$(choose_edge_checkout) + dev) + confirm_dev || { echo "Cancelled."; exit 0; } + dev_checkout=$(choose_dev_checkout) pacman_channel=edge packages=(omarchy-dev omarchy-settings-dev) ;; @@ -101,13 +101,13 @@ omarchy-refresh-pacman "$pacman_channel" # --ask 4 accepts omarchy <-> omarchy-dev replacement prompts without file overwrites. sudo env OMARCHY_UPDATE_PACMAN=1 pacman -S --needed --noconfirm --ask 4 "${packages[@]}" -if [[ -z $edge_checkout ]] && omarchy-cmd-present omarchy-dev-unlink; then +if [[ -z $dev_checkout ]] && omarchy-cmd-present omarchy-dev-unlink; then omarchy-dev-unlink export OMARCHY_PATH=/usr/share/omarchy fi omarchy-update -y -if [[ -n $edge_checkout ]]; then - sync_edge_checkout "$edge_checkout" +if [[ -n $dev_checkout ]]; then + sync_dev_checkout "$dev_checkout" fi diff --git a/default/omarchy/omarchy-menu.jsonc b/default/omarchy/omarchy-menu.jsonc index abd1ca76..c5734bd7 100644 --- a/default/omarchy/omarchy-menu.jsonc +++ b/default/omarchy/omarchy-menu.jsonc @@ -295,8 +295,8 @@ "update.time": {"icon":"","label":"Time","keywords":"clock ntp","action":"omarchy-launch-floating-terminal-with-presentation omarchy-update-time"}, "update.channel.stable": {"icon":"🟢","label":"Stable","checked":"[[ \"$(omarchy-channel-current)\" == \"stable\" ]]","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-channel-set stable'"}, "update.channel.rc": {"icon":"🟡","label":"RC","keywords":"release candidate","checked":"[[ \"$(omarchy-channel-current)\" == \"rc\" ]]","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-channel-set rc'"}, - "update.channel.dev": {"icon":"🟠","label":"Dev","keywords":"development","checked":"[[ \"$(omarchy-channel-current)\" == \"dev\" ]]","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-channel-set dev'"}, - "update.channel.edge": {"icon":"🔴","label":"Edge","keywords":"source mode development quattro","checked":"[[ \"$(omarchy-channel-current)\" == \"edge\" ]]","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-channel-set edge'"}, + "update.channel.dev": {"icon":"🟠","label":"Dev","keywords":"source mode development quattro","checked":"[[ \"$(omarchy-channel-current)\" == \"dev\" ]]","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-channel-set dev'"}, + "update.channel.edge": {"icon":"🔴","label":"Edge","keywords":"development","checked":"[[ \"$(omarchy-channel-current)\" == \"edge\" ]]","action":"omarchy-launch-floating-terminal-with-presentation 'omarchy-channel-set edge'"}, "update.process.hyprsunset": {"icon":"","label":"Hyprsunset","keywords":"restart","action":"omarchy-restart-hyprsunset"}, "update.process.osd": {"icon":"","label":"OSD","keywords":"restart","action":"omarchy-restart-shell"}, "update.process.shell": {"icon":"󰍜","label":"Shell","keywords":"restart bar quickshell omarchy-shell","action":"omarchy-restart-shell"}, diff --git a/test/shell.d/channel-test.sh b/test/shell.d/channel-test.sh index c7518b2a..644265d8 100644 --- a/test/shell.d/channel-test.sh +++ b/test/shell.d/channel-test.sh @@ -96,7 +96,7 @@ esac run_channel() { : >"$log_file" OMARCHY_CHANNEL_TEST_LOG="$log_file" \ - OMARCHY_EDGE_PATH="${OMARCHY_EDGE_PATH:-}" \ + OMARCHY_DEV_PATH="${OMARCHY_DEV_PATH:-}" \ OMARCHY_TEST_GUM_INPUT="${OMARCHY_TEST_GUM_INPUT:-}" \ OMARCHY_PATH="$ROOT" \ HOME="$test_tmp/home" \ @@ -129,33 +129,40 @@ assert_log_line $'sudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--no assert_log_line 'unlink' "stable restores the package-backed Omarchy path" assert_log_line $'update\t-y' "stable runs the normal update pipeline" -run_channel dev -assert_log_line $'refresh\tedge' "dev refreshes the edge pacman channel" -assert_log_line $'sudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--noconfirm\t--ask\t4\tomarchy-dev\tomarchy-settings-dev' "dev installs development Omarchy packages" -assert_log_line 'unlink' "dev remains package-backed" +run_channel rc +assert_log_line $'refresh\trc' "rc refreshes the rc pacman channel" +assert_log_line $'sudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--noconfirm\t--ask\t4\tomarchy\tomarchy-settings' "rc installs rc Omarchy packages" +assert_log_line 'unlink' "rc restores the package-backed Omarchy path" +assert_log_line $'update\t-y' "rc runs the normal update pipeline" -checkout="$test_tmp/edge-checkout" -default_checkout="$test_tmp/home/Work/omarchy" -OMARCHY_TEST_GUM_INPUT="$checkout" run_channel edge -assert_numbered_log_line 1 $'gum\tconfirm\t--default=false\tEnable Edge anyway?' "edge warns before changing packages" -assert_numbered_log_line 2 $'gum\tinput\t--value\t'"$default_checkout"$'\t--placeholder\t'"$default_checkout"$'\t--header\tWhere should Edge checkout live? Existing non-checkout paths will not be overwritten.' "edge prompts for the checkout path before changing packages" -assert_log_line $'gum\tconfirm\t--default=false\tEnable Edge anyway?' "edge asks for confirmation" +run_channel edge assert_log_line $'refresh\tedge' "edge refreshes the edge pacman channel" assert_log_line $'sudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--noconfirm\t--ask\t4\tomarchy-dev\tomarchy-settings-dev' "edge installs development Omarchy packages" -assert_log_line $'git\tclone\t--branch\tquattro\t--single-branch\thttps://github.com/basecamp/omarchy.git\t'"$checkout" "edge clones the quattro checkout" -assert_log_line $'link\t'"$checkout" "edge links the source checkout" +assert_log_line 'unlink' "edge remains package-backed" +assert_log_line $'update\t-y' "edge runs the normal update pipeline" + +checkout="$test_tmp/dev-checkout" +default_checkout="$test_tmp/home/Work/omarchy" +OMARCHY_TEST_GUM_INPUT="$checkout" run_channel dev +assert_numbered_log_line 1 $'gum\tconfirm\t--default=false\tEnable Dev anyway?' "dev warns before changing packages" +assert_numbered_log_line 2 $'gum\tinput\t--value\t'"$default_checkout"$'\t--placeholder\t'"$default_checkout"$'\t--header\tWhere should Dev checkout live? Existing non-checkout paths will not be overwritten.' "dev prompts for the checkout path before changing packages" +assert_log_line $'gum\tconfirm\t--default=false\tEnable Dev anyway?' "dev asks for confirmation" +assert_log_line $'refresh\tedge' "dev refreshes the edge pacman channel" +assert_log_line $'sudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--noconfirm\t--ask\t4\tomarchy-dev\tomarchy-settings-dev' "dev installs development Omarchy packages" +assert_log_line $'git\tclone\t--branch\tquattro\t--single-branch\thttps://github.com/basecamp/omarchy.git\t'"$checkout" "dev clones the quattro checkout" +assert_log_line $'link\t'"$checkout" "dev links the source checkout" occupied_checkout="$test_tmp/occupied" mkdir -p "$occupied_checkout" -if OMARCHY_TEST_GUM_INPUT="$occupied_checkout" run_channel edge >"$test_tmp/occupied.out" 2>"$test_tmp/occupied.err"; then - fail "edge refuses to use an occupied non-checkout path" +if OMARCHY_TEST_GUM_INPUT="$occupied_checkout" run_channel dev >"$test_tmp/occupied.out" 2>"$test_tmp/occupied.err"; then + fail "dev refuses to use an occupied non-checkout path" fi -grep -q "already exists and is not a git checkout" "$test_tmp/occupied.err" || fail "edge explains occupied checkout paths" "$(cat "$test_tmp/occupied.err")" +grep -q "already exists and is not a git checkout" "$test_tmp/occupied.err" || fail "dev explains occupied checkout paths" "$(cat "$test_tmp/occupied.err")" if grep -Fx $'refresh\tedge' "$log_file" >/dev/null; then - fail "edge validates checkout path before changing packages" "$(cat "$log_file")" + fail "dev validates checkout path before changing packages" "$(cat "$log_file")" fi -pass "edge refuses occupied non-checkout paths before package changes" +pass "dev refuses occupied non-checkout paths before package changes" current_channel() { OMARCHY_TEST_VERSION_CHANNEL="$1" \ @@ -169,16 +176,16 @@ current_channel() { [[ $(current_channel stable stable) == "stable" ]] || fail "current channel detects stable" pass "current channel detects stable" -[[ $(current_channel rc dev) == "rc" ]] || fail "current channel detects rc" +[[ $(current_channel rc stable) == "rc" ]] || fail "current channel detects rc" pass "current channel detects rc" -[[ $(current_channel edge dev /dev/null /usr/share/omarchy) == "dev" ]] || fail "current channel detects package-backed dev" -pass "current channel detects package-backed dev" +[[ $(current_channel edge dev /dev/null /usr/share/omarchy) == "edge" ]] || fail "current channel detects package-backed edge" +pass "current channel detects package-backed edge" -[[ $(current_channel edge dev /dev/null "$test_tmp/edge-checkout") == "edge" ]] || fail "current channel detects edge from OMARCHY_PATH" -pass "current channel detects edge from OMARCHY_PATH" +[[ $(current_channel edge dev /dev/null "$test_tmp/dev-checkout") == "dev" ]] || fail "current channel detects dev from OMARCHY_PATH" +pass "current channel detects dev from OMARCHY_PATH" conf="$test_tmp/omarchy.conf" -printf 'export OMARCHY_PATH="%s"\n' "$test_tmp/edge-checkout" >"$conf" -[[ $(current_channel edge dev "$conf" /usr/share/omarchy) == "edge" ]] || fail "current channel detects edge from configured path" -pass "current channel detects edge from configured path" +printf 'export OMARCHY_PATH="%s"\n' "$test_tmp/dev-checkout" >"$conf" +[[ $(current_channel edge dev "$conf" /usr/share/omarchy) == "dev" ]] || fail "current channel detects dev from configured path" +pass "current channel detects dev from configured path"