Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ curl -fsSL https://raw.githubusercontent.com/TattvaOrg/agility-shell/main/instal
>[!NOTE]
>The installer automatically scans `~/.config/agility-shell` for any old monolithic shell installations, removes old source files and venvs, and safely migrates your custom configs, themes, wallpapers, and styles to the new clean config directory.

### 3. Update Agility Shell (One-Liner Delta Update)
To update Agility Shell without re-cloning the entire repository:

```bash
curl -fsSL https://raw.githubusercontent.com/TattvaOrg/agility-shell/main/update.sh | bash
```

> **Channel Selection**: The updater interactively asks whether to update to the **Latest Release** (stable tag) or the bleeding-edge **`main` branch**. It reuses the persistent local repository cache (`~/.cache/agility-shell/repo`), downloads only new commits/deltas instead of full re-clones, compiles updated snippets, and preserves all user configurations (`config.json`, `suits.json`, `style/`, `wallpapers/`).
>
> **Direct Channel Flags**:
> - Update to Latest Release: `curl -fsSL https://raw.githubusercontent.com/TattvaOrg/agility-shell/main/update.sh | bash -s -- --release`
> - Update to Bleeding-Edge Main: `curl -fsSL https://raw.githubusercontent.com/TattvaOrg/agility-shell/main/update.sh | bash -s -- --main`
> - Or directly from terminal: `agl update`

---

## Filesystem Layout & Architecture ("Where & Why")
Expand Down Expand Up @@ -82,6 +96,7 @@ agl <command> [options]
| `agl uninstall` | Cleanly uninstall Agility Shell | `agl uninstall` (or `agl uninstall --purge`) |
| `agl install` | Run or rerun system installer | `agl install` |
| `agl suits` | Manage desktop suites (switch, list, next, prev) | `agl suits next` |
| `agl bar` | Adjust bar thickness dynamically (`agl bar height <26-48>`) | `agl bar height 36` |

---

Expand Down
15 changes: 9 additions & 6 deletions bin/agl
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,15 @@ cmd_update() {
elif [[ -f "/usr/share/agility-shell/scripts/update.sh" ]]; then
exec "/usr/share/agility-shell/scripts/update.sh" "$@"
else
local tmp_dir
tmp_dir="$(mktemp -d)"
trap 'rm -rf "$tmp_dir"' EXIT
curl -fsSL https://raw.githubusercontent.com/TattvaOrg/agility-shell/main/scripts/update.sh -o "$tmp_dir/update.sh"
chmod +x "$tmp_dir/update.sh"
exec "$tmp_dir/update.sh" "$@"
local cache_repo="${XDG_CACHE_HOME:-$HOME/.cache}/agility-shell/repo"
if [[ -d "$cache_repo/.git" ]]; then
(cd "$cache_repo" && git remote set-url origin "https://github.com/TattvaOrg/agility-shell.git" 2>/dev/null || true && git fetch --prune --tags origin)
exec "$cache_repo/scripts/update.sh" "$@"
else
mkdir -p "$(dirname "$cache_repo")"
git clone "https://github.com/TattvaOrg/agility-shell.git" "$cache_repo"
exec "$cache_repo/scripts/update.sh" "$@"
fi
fi
}

Expand Down
120 changes: 109 additions & 11 deletions scripts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,104 @@ check_not_root() {
}

do_update() {
info "Checking for Agility Shell updates..."
local tmp_clone
tmp_clone="$(mktemp -d)"
trap 'rm -rf "$tmp_clone"' EXIT
local target_channel=""

# Parse arguments
while [[ $# -gt 0 ]]; do
case "$1" in
--main|-m)
target_channel="main"
shift
;;
--release|-r|--stable)
target_channel="release"
shift
;;
--help|-h)
echo -e "${BOLD}Usage:${RESET} update.sh [options]"
echo -e " ${CYAN}--release, -r${RESET} Update to latest stable release tag"
echo -e " ${CYAN}--main, -m${RESET} Update to bleeding-edge main branch"
echo -e " ${CYAN}--help, -h${RESET} Show this help message"
exit 0
;;
*)
shift
;;
esac
done

info "Locating Agility Shell repository..."
local repo_dir=""
if [[ -d "$SCRIPT_DIR/../.git" ]]; then
repo_dir="$(cd "$SCRIPT_DIR/.." && pwd)"
info "Using in-tree repository at $repo_dir"
else
local cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/agility-shell"
repo_dir="$cache_dir/repo"
if [[ -d "$repo_dir/.git" ]]; then
info "Reusing persistent repository cache at $repo_dir"
else
info "Initializing repository cache at $repo_dir..."
mkdir -p "$cache_dir"
git clone "$REPO_URL" "$repo_dir"
fi
fi

info "Cloning latest sources from $REPO_URL..."
git clone --depth 1 "$REPO_URL" "$tmp_clone/repo"
cd "$repo_dir"
info "Fetching delta changes and release tags from remote..."
git remote set-url origin "$REPO_URL" 2>/dev/null || true
git fetch --prune --tags origin

# Discover available latest release tag and current checkout state
local latest_tag
latest_tag=$(git tag -l --sort=-v:refname | grep -E '^[0-9]+(\.[0-9]+)+' | head -n 1)
if [[ -z "$latest_tag" ]]; then
latest_tag=$(git tag -l --sort=-v:refname | head -n 1)
fi
latest_tag="${latest_tag:-1.0.1}"

cd "$tmp_clone/repo"
local current_desc
current_desc=$(git describe --tags --always 2>/dev/null || echo "unknown")

echo ""
echo -e " ${BOLD}Current local version:${RESET} ${CYAN}$current_desc${RESET}"
echo -e " ${BOLD}Latest release tag:${RESET} ${GREEN}v$latest_tag${RESET}"
echo ""

if [[ -z "$target_channel" ]]; then
echo -e "${BOLD}Select update channel:${RESET}"
echo -e " ${GREEN}[1]${RESET} Latest Release (${GREEN}v$latest_tag${RESET}) - ${DIM}Recommended: Tested, stable version${RESET}"
echo -e " ${CYAN}[2]${RESET} Main branch (${CYAN}bleeding edge${RESET}) - ${DIM}Latest commits & newest features${RESET}"
echo ""
prompt_user " Enter choice [1/2] (default: 1): " channel_choice "1"
case "$channel_choice" in
2|[mM]|[mM][aA][iI][nN])
target_channel="main"
;;
*)
target_channel="release"
;;
esac
fi

local target_ref=""
local target_name=""
if [[ "$target_channel" == "main" ]]; then
target_ref="origin/main"
target_name="main (latest development)"
info "Switching to $target_name..."
git checkout -f main 2>/dev/null || git checkout -b main origin/main
git reset --hard origin/main
else
target_ref="tags/$latest_tag"
target_name="Release v$latest_tag (stable)"
info "Switching to $target_name..."
git checkout -f "$target_ref"
fi

local updated_desc
updated_desc=$(git describe --tags --always 2>/dev/null || git rev-parse --short HEAD)
success "Repository updated to: $updated_desc"

local is_pacman=false
if pacman -Q agility-shell-git &>/dev/null || pacman -Q agility-shell &>/dev/null; then
Expand All @@ -106,23 +195,32 @@ do_update() {
info "Updating native Arch pacman package via makepkg..."
makepkg -sif --noconfirm
else
info "Rebuilding and updating system files via make install..."
info "Compiling native snippet libraries..."
make
info "Updating system files via make install..."
sudo make PREFIX="/usr" install
sudo make PREFIX="/usr" install-venv

local venv_pip="/usr/lib/agility-shell/venv/bin/pip"
if [[ -x "$venv_pip" ]]; then
info "Synchronizing runtime Python dependencies (delta only)..."
sudo "$venv_pip" install -r requirements.txt -q
else
info "Provisioning virtual environment..."
sudo make PREFIX="/usr" install-venv
fi
fi

if command -v systemctl &>/dev/null; then
systemctl --user daemon-reload || true
fi

echo
success "Agility Shell updated successfully!"
success "Agility Shell successfully updated!"
echo
prompt_user " Would you like to restart Agility Shell now? [Y/n]: " restart_choice "y"
case "$restart_choice" in
[nN]|[nN][oO])
info "Restart skipped. Run 'agl restart' when ready."
info "Restart skipped. Run 'agl restart' whenever you are ready."
;;
*)
if command -v agl &>/dev/null; then
Expand Down
24 changes: 18 additions & 6 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,21 @@ if [[ -n "$SCRIPT_DIR" && -f "$SCRIPT_DIR/scripts/update.sh" ]]; then
exec "$SCRIPT_DIR/scripts/update.sh" "$@"
fi

# Fallback when running piped via curl/stdin without a git clone
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT
curl -fsSL https://raw.githubusercontent.com/TattvaOrg/agility-shell/main/scripts/update.sh -o "$TMP_DIR/update.sh"
chmod +x "$TMP_DIR/update.sh"
exec "$TMP_DIR/update.sh" "$@"
# Fallback when running piped via curl/stdin without an in-tree git clone:
# Reuse persistent cache (~/.cache/agility-shell/repo) so only delta changes are downloaded
CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/agility-shell"
REPO_DIR="$CACHE_DIR/repo"
REPO_URL="https://github.com/TattvaOrg/agility-shell.git"

if [[ -d "$REPO_DIR/.git" ]]; then
echo "[agility] Reusing repository cache at $REPO_DIR (fetching deltas only)..."
cd "$REPO_DIR"
git remote set-url origin "$REPO_URL" 2>/dev/null || true
git fetch --prune --tags origin
else
echo "[agility] Initializing repository cache at $REPO_DIR..."
mkdir -p "$CACHE_DIR"
git clone "$REPO_URL" "$REPO_DIR"
fi

exec "$REPO_DIR/scripts/update.sh" "$@"