Update Omarchy channel switcher

This commit is contained in:
Ryan Hughes
2026-06-09 13:05:30 -04:00
parent 22a42e073a
commit 9b8c9fd537
4 changed files with 340 additions and 14 deletions
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
# omarchy:summary=Print the active Omarchy package channel
set -euo pipefail
conf=${OMARCHY_CONFIG_FILE:-/etc/omarchy.conf}
omarchy_path=${OMARCHY_PATH:-/usr/share/omarchy}
if [[ -r $conf ]]; then
configured_path=$(bash -c 'source "$1"; printf "%s\n" "${OMARCHY_PATH:-}"' bash "$conf" 2>/dev/null || true)
[[ -n $configured_path ]] && omarchy_path="$configured_path"
fi
channel=$(omarchy-version-channel 2>/dev/null | awk '{ print $1 }')
if pacman -Q omarchy-dev omarchy-settings-dev >/dev/null 2>&1; then
case "$channel" in
rc) echo rc ;;
edge)
if [[ $omarchy_path == "/usr/share/omarchy" ]]; then
echo dev
else
echo live-dev
fi
;;
*) echo unknown ;;
esac
elif pacman -Q omarchy omarchy-settings >/dev/null 2>&1 && [[ $channel == "stable" ]]; then
echo stable
else
echo unknown
fi
+111 -9
View File
@@ -1,21 +1,123 @@
#!/bin/bash
# omarchy:summary=Set the Omarchy package channel.
# omarchy:args=<stable|rc|edge|dev>
# omarchy:args=<stable|rc|dev|live-dev>
# omarchy:requires-sudo=true
set -e
set -euo pipefail
if (($# == 0)); then
echo "Usage: omarchy-channel-set [stable|rc|edge|dev]"
exit 1
fi
usage() { echo "Usage: omarchy-channel-set [stable|rc|dev|live-dev]"; }
fail() { echo "Error: $*" >&2; exit 1; }
confirm_live_dev() {
cat <<'WARNING'
Live 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
responsible for pulling, fixing, and restoring that checkout yourself.
WARNING
if omarchy-cmd-present gum; then
gum confirm --default=false "Enable Live Dev anyway?"
else
local answer=""
read -r -p "Enable Live Dev anyway? [y/N] " answer
[[ $answer == "y" || $answer == "Y" || $answer == "yes" || $answer == "YES" ]]
fi
}
choose_live_dev_checkout() {
local default_path="$HOME/Work/omarchy"
local path="${OMARCHY_LIVE_DEV_PATH:-}"
if [[ -z $path ]]; then
if omarchy-cmd-present gum; then
path=$(gum input --value "$default_path" --placeholder "$default_path" --header "Where should Live Dev checkout live? Existing non-checkout paths will not be overwritten.") || exit 1
else
read -r -p "Live Dev checkout path [$default_path]: " path
fi
fi
path="${path:-$default_path}"
case "$path" in
"~") path="$HOME" ;;
"~/"*) path="$HOME/${path#~/}" ;;
/*) ;;
*) path="$PWD/$path" ;;
esac
if [[ -e $path && ! -d $path/.git ]]; then
fail "$path already exists and is not a git checkout. Choose an empty path or an existing Omarchy checkout."
fi
if [[ -d $path/.git && ( ! -d $path/bin || ! -d $path/default || ! -d $path/shell ) ]]; then
fail "$path is a git checkout, but it does not look like Omarchy."
fi
printf '%s\n' "$path"
}
sync_live_dev_checkout() {
local checkout="$1"
if [[ -d $checkout/.git ]]; then
echo "Updating Live 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
else
mkdir -p "$(dirname -- "$checkout")"
git clone --branch quattro --single-branch https://github.com/basecamp/omarchy.git "$checkout"
fi
omarchy-dev-link "$checkout"
}
(( $# > 0 )) || { usage; exit 1; }
live_dev_checkout=""
channel="$1"
case "$channel" in
stable|rc|edge) omarchy-refresh-pacman "$channel" ;;
dev) omarchy-refresh-pacman edge ;;
*) echo "Unknown channel: $channel"; exit 1 ;;
stable)
pacman_channel=stable
packages=(omarchy omarchy-settings)
;;
rc)
pacman_channel=rc
packages=(omarchy-dev omarchy-settings-dev)
;;
dev)
pacman_channel=edge
packages=(omarchy-dev omarchy-settings-dev)
;;
live-dev|live|source)
confirm_live_dev || { echo "Cancelled."; exit 0; }
live_dev_checkout=$(choose_live_dev_checkout)
pacman_channel=edge
packages=(omarchy-dev omarchy-settings-dev)
;;
*)
echo "Unknown channel: $channel" >&2
usage >&2
exit 1
;;
esac
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 $live_dev_checkout ]] && omarchy-cmd-present omarchy-dev-unlink; then
omarchy-dev-unlink
export OMARCHY_PATH=/usr/share/omarchy
fi
omarchy-update -y
if [[ -n $live_dev_checkout ]]; then
sync_live_dev_checkout "$live_dev_checkout"
fi