#!/bin/bash # omarchy:summary=Set the Omarchy package channel. # omarchy:args= # omarchy:requires-sudo=true set -euo pipefail usage() { echo "Usage: omarchy-channel-set [stable|rc|edge|dev]"; } fail() { echo "Error: $*" >&2; exit 1; } confirm_dev() { cat <<'WARNING' 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 gum confirm --default=false "Enable Dev anyway?" } validate_dev_checkout() { local checkout="$1" if [[ -e $checkout && ! -d $checkout/.git ]]; then fail "$checkout already exists and is not a git checkout." fi if [[ -d $checkout/.git && ( ! -d $checkout/bin || ! -d $checkout/default || ! -d $checkout/shell ) ]]; then fail "$checkout is a git checkout, but it does not look like Omarchy." fi } link_dev_checkout() { local checkout="$1" [[ -d $checkout/.git ]] || git clone https://github.com/basecamp/omarchy.git "$checkout" omarchy-dev-link "$checkout" } (( $# > 0 )) || { usage; exit 1; } dev_checkout="" channel="$1" leaving_dev=0 case "$channel" in stable) pacman_channel=stable packages=(omarchy omarchy-settings) ;; rc) pacman_channel=rc packages=(omarchy omarchy-settings) ;; edge) pacman_channel=edge packages=(omarchy-dev omarchy-settings-dev) ;; dev) confirm_dev || { echo "Cancelled."; exit 0; } dev_checkout="$HOME/omarchy" validate_dev_checkout "$dev_checkout" pacman_channel=edge packages=(omarchy-dev omarchy-settings-dev) ;; *) echo "Unknown channel: $channel" >&2 usage >&2 exit 1 ;; esac if [[ -z $dev_checkout && $OMARCHY_PATH != "/usr/share/omarchy" ]]; then leaving_dev=1 fi 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 $dev_checkout ]]; then omarchy-dev-unlink --no-reboot export OMARCHY_PATH=/usr/share/omarchy if (( leaving_dev )); then omarchy-state set reboot-required fi fi omarchy-update -y if [[ -n $dev_checkout ]]; then link_dev_checkout "$dev_checkout" fi