From e237c7d22a07b498bda8273e12a7cae807eca49c Mon Sep 17 00:00:00 2001 From: Lukasz Boryn Date: Thu, 18 Jun 2026 00:21:01 +0200 Subject: [PATCH] feat(installer): replace webapp-cleaner with config_installer webapp-cleaner only removed web apps. config_installer runs the whole Omarchy 4 post-install pass: remove preinstalls, then add tools. * feat(installer): remove preinstalled packages, web apps and their shortcuts * feat(installer): add tools via pacman, AUR, mise, uv and rustup * feat(installer): preview with --dry-run and verify actions in a summary * docs(readme): document the configurator and its quick start --- README.md | 117 ++++- config_installer.sh | 565 +++++++++++++++++++++ webapp-cleaner.sh | 1159 ------------------------------------------- 3 files changed, 660 insertions(+), 1181 deletions(-) create mode 100755 config_installer.sh delete mode 100644 webapp-cleaner.sh diff --git a/README.md b/README.md index f4fff89..e7e5c85 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ## Table of Contents - [Overview](#overview) -- [App cleanup](#app-cleanup) +- [Configurator](#configurator) - [Packages](#packages) - [Default browser](#default-browser) - [NVIDIA](#nvidia) @@ -36,22 +36,101 @@ and the shell prompt. > Commands below are recorded as run on the author's machine. Verify package > names and paths against your own hardware before applying. -## App cleanup - -Omarchy ships several web apps that may not fit your needs. The original -selector script comes from `omarchy-cleaner`: +Quick start: ```bash -curl -fsSL https://raw.githubusercontent.com/maxart/omarchy-cleaner/main/omarchy-cleaner.sh | bash +./config_installer.sh --dry-run # preview: changes nothing +./config_installer.sh # step 1: remove, step 2: add ``` -> Piping a remote script straight to a shell runs unreviewed code. Download -> and read it first if you are unsure what it removes. +## Configurator -The version checked in here pre-selects the items relevant to this setup: +`config_installer.sh` runs two steps. Each one asks first, so either can be +skipped, and every item can be ticked or unticked in a menu. Re-running is +safe: anything already in the desired state is left alone. + +### Step 1 — Remove + +Omarchy 4 preinstalls web apps (Basecamp, Discord, Google Contacts / Maps / +Messages / Photos, HEY, WhatsApp, X, YouTube, Zoom) and desktop apps (Aether, +cliamp, Omacalc, Omacut, Omawrite, Pinta, …). To drop all of them at once, +Omarchy provides `omarchy-remove-preinstalls`. Step 1 lets you pick: + +- installed packages from the `REMOVABLE_PACKAGES` list at the top of the + script (uncomment entries to offer more), plus every installed web app + launcher — including ones you created yourself. Nothing is preselected; +- packages are removed with `pacman -Rns`, web apps with `omarchy-webapp-remove`; +- it offers to disable the default shortcuts that launch removed items by + appending `hl.unbind("…")` lines to `~/.config/hypr/bindings.lua` (a backup + is made first). Omarchy's defaults live in + `/usr/share/omarchy/default/hypr/bindings/applications.lua` and must not be + edited directly. + +Adapted from [omarchy-cleaner](https://github.com/maxart/omarchy-cleaner). + +> Web apps open in Chromium unless the default browser is Chromium-based +> (Chrome, Brave, Edge, Vivaldi, Opera, Helium). Removing `chromium` while +> keeping web apps leaves them unable to launch — the script warns about this. + +### Step 2 — Add + +Everything is preselected; untick what you do not want. The list lives in the +`CATALOGUE` array at the top of the script. + +| Group | Item | Installed via | +| --- | --- | --- | +| Desktop | [LibreWolf](https://librewolf.net/) | AUR `librewolf-bin` (binary, much faster than building `librewolf`) | +| System | [herdr](https://github.com/herdrdev/herdr) (terminal workspace for AI agents), [caligula](https://github.com/ifd3f/caligula) (disk image writer) | pacman | +| Dev CLI | [just](https://just.systems/), [uv](https://docs.astral.sh/uv/), [ty](https://docs.astral.sh/ty/), [jj](https://jj-vcs.github.io/jj/), [pi](https://github.com/earendil-works/pi) coding agent, [hunk](https://github.com/modem-dev/hunk) diff viewer | `mise use -g` | +| Rust + Python | [rustup](https://rustup.rs/) + `rust-analyzer`, `clippy`, `rustfmt` | pacman, then `rustup` | +| Rust + Python | [maturin](https://www.maturin.rs/) | `uv tool install` | +| Rust + Python | `cmake`, `pkgconf` (for `-sys` crates such as `rust-htslib`) | pacman | +| Profiling | `cargo-binstall`, `perf` | pacman | +| Profiling | [py-spy](https://github.com/benfred/py-spy) (`py-spy record --native` shows Rust frames) | `uv tool install` | + +Why these sources: + +- **mise for dev CLIs** — upstream's prebuilt binaries on release day, + per-project pinning via `mise.toml`, no sudo, and it is how Omarchy already + ships its AI/dev CLIs. Update with `mise up`. ty is still beta (0.0.x), so + release-day updates matter most there. Omarchy's lazy `~/.local/bin/pi` and + `~/.local/bin/hunk` stubs use the same backends and keep working. +- **pacman for system tools** — updated by `omarchy-update`. +- **No `cargo install`** — just, uv, ty and jj ship prebuilt binaries; + compiling them needs the Rust toolchain and gets no automatic updates. +- **rustup instead of Arch's `rust`** — per-project `rust-toolchain.toml`, + nightly for `miri`, extra targets for manylinux/musllinux wheels and + `llvm-tools` for PGO. Replacing the `rust` package is asked first. +- **uv for Python-side tools** — maturin and py-spy ship as wheels with the + binary inside. Manage Python versions with `uv python install`. + +Before installing a mise tool, the script looks for other copies on `PATH` +(cargo installs, AUR `-git` packages such as `jujutsu-git`, npm globals, +standalone installers). If a copy is older than the version mise would install, +it offers to remove it so it cannot shadow the new one. Copies of unknown +origin are left alone. + +### Summary + +The run ends with a table: + +| item | status | action verified | +| --- | --- | --- | +| tool or app name | `installed`, `removed` or `kept` | `yes` / `no` | + +`kept` covers unselected items, items already in place, declined prompts and +failures. *Action verified* re-checks the result (package or command present, +or gone after removal); a failed action shows `kept` / `no`. + +### Dry run + +`--dry-run` walks both steps and prints every command it would run plus the +summary, changing nothing (*action verified* is always `no`). Without a +terminal it selects every item and answers every prompt with yes, so the full +path can be checked unattended: ```bash -bash webapp-cleaner.sh +./config_installer.sh --dry-run < /dev/null ``` ## Packages @@ -68,14 +147,8 @@ sudo pacman -S fcitx5-config-qt fcitx5-configtool fcitx5-gtk ## Default browser -Install the `librewolf-bin` binary package — it is noticeably faster to set up -than building `librewolf` from source: - -```bash -yay -S librewolf-bin -``` - -Make LibreWolf the default browser so it matches the assigned keybinding: +LibreWolf is installed by [step 2](#step-2--add). Make it the default browser +so it matches the assigned keybinding: ```bash echo 'export BROWSER=librewolf' >> /home/$USER/.config/uwsm/default @@ -211,11 +284,11 @@ cp src/starship.toml ~/.config/ ## Repository layout ``` -webapp-cleaner.sh # interactive selector to remove bundled Omarchy web apps +config_installer.sh # step 1: remove preinstalled apps/web apps; step 2: add tools src/ - starship.toml # Starship shell-prompt config (copy to ~/.config/) -LICENSE # MIT -README.md # this guide + starship.toml # Starship shell-prompt config (copy to ~/.config/) +LICENSE # MIT +README.md # this guide ``` ## License diff --git a/config_installer.sh b/config_installer.sh new file mode 100755 index 0000000..30b8ff9 --- /dev/null +++ b/config_installer.sh @@ -0,0 +1,565 @@ +#!/bin/bash + +# Omarchy 4 post-install configurator. +# +# Step 1 - Remove: pick preinstalled packages and web apps to remove, and +# optionally disable their default shortcuts. +# Step 2 - Add: pick desktop, system and developer tools to install. +# +# Ends with a summary table: item | status | action verified. +# +# Usage: config_installer.sh [--dry-run] +# +# --dry-run Show what would happen without changing anything. Without a +# terminal, every item is selected and every prompt answered yes, +# so the whole path runs unattended. +# +# Step 1 is adapted from https://github.com/maxart/omarchy-cleaner. For an +# all-or-nothing cleanup, Omarchy ships `omarchy-remove-preinstalls`. + +OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}" +APP_BINDINGS="$OMARCHY_PATH/default/hypr/bindings/applications.lua" +USER_BINDINGS="$HOME/.config/hypr/bindings.lua" +DESKTOP_DIR="$HOME/.local/share/applications" + +# Tools from mise install and upgrade as soon as they ship, as in Omarchy's +# own mise stubs. +export MISE_MINIMUM_RELEASE_AGE=0 + +# --------------------------------------------------------------------------- +# Step 1 candidates: packages offered for removal (shown only when installed). +# Base list: $OMARCHY_PATH/install/omarchy-base.packages +# --------------------------------------------------------------------------- +REMOVABLE_PACKAGES=( + # Optional services - not preinstalled in Omarchy 4, but often added later + "1password-beta" + "1password-cli" + "signal-desktop" + "spotify" + + # Web apps fall back to chromium unless the default browser is Chromium-based + "chromium" + + # Preinstalls also removed by `omarchy-remove-preinstalls` + "aether" + "cliamp" + "moonlight-qt" + "omacalc" + "omacut" + "omawrite" + "pinta" + + # Uncomment to offer for removal + # "kdenlive" # video editing + # "libreoffice-fresh" # office suite + # "localsend" # cross-platform file sharing + # "obs-studio" # screencasting and streaming + # "obsidian" # markdown notes + # "xournalpp" # handwritten notes, useful in meetings + # "lazydocker" # docker TUI + # "docker" "docker-buildx" "docker-compose" # keep: classic docker setup +) + +# --------------------------------------------------------------------------- +# Step 2 catalogue: "item|group|method|target|command" +# method: pacman, aur, mise (global), uvtool (uv tool install), rustup +# target: package / mise tool / PyPI name +# command: binary used to detect existing copies (mise) and verify installs +# --------------------------------------------------------------------------- +CATALOGUE=( + "librewolf|Desktop|aur|librewolf-bin|librewolf" + "herdr|System|pacman|herdr|herdr" + "caligula|System|pacman|caligula|caligula" + "just|Dev CLI|mise|just|just" + "uv|Dev CLI|mise|uv|uv" + "ty|Dev CLI|mise|ty|ty" + "jj|Dev CLI|mise|jj|jj" + "pi|Dev CLI|mise|pi|pi" + "hunk|Dev CLI|mise|aqua:modem-dev/hunk|hunk" + "rustup|Rust + Python|rustup|rustup|rustup" + "maturin|Rust + Python|uvtool|maturin|maturin" + "cmake|Rust + Python|pacman|cmake|cmake" + "pkgconf|Rust + Python|pacman|pkgconf|pkgconf" + "cargo-binstall|Profiling|pacman|cargo-binstall|cargo-binstall" + "py-spy|Profiling|uvtool|py-spy|py-spy" + "perf|Profiling|pacman|perf|perf" +) + +RUST_COMPONENTS=(rust-analyzer clippy rustfmt) + +DRY_RUN=false +INTERACTIVE=false +[[ -t 0 && -t 1 ]] && INTERACTIVE=true + +SUMMARY=() # "itemstatusverified" + +# --------------------------------------------------------------------------- +# UI helpers - fall back to defaults (select all, answer yes) when unattended +# --------------------------------------------------------------------------- + +info() { printf '\033[1;34m==> %s\033[0m\n' "$*"; } +warn() { printf '\033[1;33m⚠ %s\033[0m\n' "$*"; } +note() { printf ' %s\n' "$*"; } + +confirm() { + if $INTERACTIVE; then + gum confirm "$1" + else + note "$1 → yes (unattended)" + fi +} + +# choose
; prints the selection. +choose() { + local header="$1" preselect="$2" + shift 2 + if $INTERACTIVE; then + local selected=() + [[ $preselect == all ]] && selected=(--selected "$(IFS=,; echo "$*")") + gum choose --no-limit --height 20 --header "$header" "${selected[@]}" "$@" + else + printf '%s\n' "$@" + fi +} + +# Run a command, or only print it in dry-run mode. +run() { + if $DRY_RUN; then + local line + printf -v line '%q ' "$@" + note "would run: ${line/#uv_cmd/uv}" + else + "$@" + fi +} + +# A dry run verifies nothing, so every row says "no" there. +record() { + local verified="$3" + $DRY_RUN && verified=no + SUMMARY+=("$1"$'\t'"$2"$'\t'"$verified") +} + +# Record an attempted action: verified only when the check passes for real. +record_action() { + local item="$1" status="$2" check="$3" + if $DRY_RUN; then + record "$item" "$status" no + elif eval "$check"; then + record "$item" "$status" yes + else + record "$item" kept no + fi +} + +# --------------------------------------------------------------------------- +# Step 1 - Remove +# --------------------------------------------------------------------------- + +installed_packages() { + local pkg + for pkg in "${REMOVABLE_PACKAGES[@]}"; do + pacman -Qq "$pkg" &>/dev/null && echo "$pkg" + done +} + +# Same detection as omarchy-webapp-remove: any launcher run through Omarchy's +# web app launcher or one of its URL handlers. +installed_webapps() { + local file + for file in "$DESKTOP_DIR"/*.desktop; do + [[ -f $file ]] || continue + grep -q '^Exec=.*\(omarchy-launch-webapp\|omarchy-webapp-handler\)' "$file" && + basename "${file%.desktop}" + done | sort -f +} + +# Host of a URL without scheme, path and leading "www.". +url_host() { + local host="${1#*://}" + host="${host%%/*}" + echo "${host#www.}" +} + +# Default application bindings (applications.lua) that launch the given item, +# printed as "KEYLabel". Packages match on their base name in the action; +# web apps match on the host of their URL, or the handler name for HEY/Zoom. +find_bindings() { + local kind="$1" name="$2" needle="" handler="" host="" exec_line line url + [[ -f $APP_BINDINGS ]] || return + + if [[ $kind == package ]]; then + needle="${name%-desktop}" + needle="${needle%-beta}" + needle="${needle%-cli}" + [[ $name == lazydocker ]] && needle="docker-tui" + [[ $name == chromium ]] && return # bound as the generic "browser" action + else + exec_line=$(grep -m1 '^Exec=' "$DESKTOP_DIR/$name.desktop" 2>/dev/null) + if [[ $exec_line =~ omarchy-webapp-handler-([a-z0-9]+) ]]; then + handler="${BASH_REMATCH[1]}" + elif [[ $exec_line =~ (https?:/+[^\"\' ]+) ]]; then + host=$(url_host "${BASH_REMATCH[1]}") + fi + [[ -n $handler || -n $host ]] || return + fi + + while IFS= read -r line; do + [[ $line =~ o\.bind\(\ *\"([^\"]+)\",\ *\"([^\"]+)\" ]] || continue + local key="${BASH_REMATCH[1]}" label="${BASH_REMATCH[2]}" + + if [[ $kind == package ]]; then + [[ $line =~ (omarchy|launch|tui)\ *=\ *\"[^\"]*$needle ]] || continue + elif [[ $line =~ webapp\ *=\ *\"([^\"]+)\" ]]; then + url=$(url_host "${BASH_REMATCH[1]}") + if [[ -n $handler ]]; then + [[ $url == *"$handler"* ]] || continue + else + [[ $url == "$host" ]] || continue + fi + else + continue + fi + printf '%s\t%s\n' "$key" "$label" + done <"$APP_BINDINGS" +} + +# Disable bindings by appending hl.unbind() calls to the user bindings file. +unbind_keys() { + local keys=("$@") key added=0 + ((${#keys[@]})) || return 0 + + if $DRY_RUN; then + note "would add to $USER_BINDINGS:" + printf ' hl.unbind("%s")\n' "${keys[@]}" + return 0 + fi + + mkdir -p "$(dirname "$USER_BINDINGS")" + touch "$USER_BINDINGS" + cp "$USER_BINDINGS" "$USER_BINDINGS.backup.$(date +%Y%m%d_%H%M%S)" + + for key in "${keys[@]}"; do + grep -qF "hl.unbind(\"$key\")" "$USER_BINDINGS" && continue + if ((added++ == 0)); then + printf '\n-- Unbound by config_installer.sh for removed apps\n' >>"$USER_BINDINGS" + fi + printf 'hl.unbind("%s")\n' "$key" >>"$USER_BINDINGS" + done + + note "Disabled $added shortcut(s) in $USER_BINDINGS" + hyprctl reload &>/dev/null +} + +step_remove() { + info "Step 1 - Remove preinstalled apps and web apps" + + local packages webapps item + readarray -t packages < <(installed_packages) + readarray -t webapps < <(installed_webapps) + + if ((${#packages[@]} + ${#webapps[@]} == 0)); then + note "Nothing to remove." + return + fi + + # Menu entries carry a type prefix so names with spaces stay unambiguous. + local options=() + for item in "${packages[@]}"; do options+=("📦 $item"); done + for item in "${webapps[@]}"; do options+=("🌐 $item"); done + + local selection + selection=$(choose "Select items to remove (space to toggle, enter to confirm)" none "${options[@]}") + + local sel_packages=() sel_webapps=() + while IFS= read -r item; do + case "$item" in + "📦 "*) sel_packages+=("${item#📦 }") ;; + "🌐 "*) sel_webapps+=("${item#🌐 }") ;; + esac + done <<<"$selection" + + # Everything not selected stays. + for item in "${packages[@]}"; do + [[ " ${sel_packages[*]} " == *" $item "* ]] || record "$item" kept yes + done + for item in "${webapps[@]}"; do + printf '%s\n' "${sel_webapps[@]}" | grep -qxF "$item" || record "$item (web app)" kept yes + done + + ((${#sel_packages[@]} + ${#sel_webapps[@]})) || { note "Nothing selected."; return; } + + echo "Selected for removal:" + for item in "${sel_packages[@]}"; do note "📦 $item"; done + for item in "${sel_webapps[@]}"; do note "🌐 $item"; done + + # Removing chromium breaks any web app left behind unless the default + # browser is Chromium-based (see omarchy-launch-webapp). + if printf '%s\n' "${sel_packages[@]}" | grep -qx chromium && + ((${#webapps[@]} > ${#sel_webapps[@]})); then + warn "Remaining web apps open in chromium unless the default browser is" + warn "Chrome, Brave, Edge, Vivaldi, Opera or Helium. They will stop launching." + fi + + # Default shortcuts launching the selection. + local keys=() summary=() key label + for item in "${sel_packages[@]}"; do + while IFS=$'\t' read -r key label; do + [[ -n $key ]] && keys+=("$key") && summary+=("⌨ $key → $label") + done < <(find_bindings package "$item") + done + for item in "${sel_webapps[@]}"; do + while IFS=$'\t' read -r key label; do + [[ -n $key ]] && keys+=("$key") && summary+=("⌨ $key → $label") + done < <(find_bindings webapp "$item") + done + readarray -t keys < <(printf '%s\n' "${keys[@]}" | sed '/^$/d' | sort -u) + + local unbind=false + if ((${#keys[@]})); then + echo "Default shortcuts launching these items:" + printf ' %s\n' "${summary[@]}" | sort -u + confirm "Disable these shortcuts in ~/.config/hypr/bindings.lua?" && unbind=true + fi + + if ! confirm "Remove the selected items? This cannot be undone."; then + for item in "${sel_packages[@]}"; do record "$item" kept yes; done + for item in "${sel_webapps[@]}"; do record "$item (web app)" kept yes; done + return + fi + + $unbind && unbind_keys "${keys[@]}" + + for item in "${sel_packages[@]}"; do + run sudo pacman -Rns --noconfirm "$item" + record_action "$item" removed "! pacman -Qq '$item' &>/dev/null" + done + for item in "${sel_webapps[@]}"; do + run env OMARCHY_REMOVE_NOTIFY=false omarchy-webapp-remove "$item" + record_action "$item (web app)" removed "[[ ! -e '$DESKTOP_DIR/$item.desktop' ]]" + done + ((${#sel_webapps[@]})) && ! $DRY_RUN && update-desktop-database "$DESKTOP_DIR" &>/dev/null +} + +# --------------------------------------------------------------------------- +# Step 2 - Add +# --------------------------------------------------------------------------- + +# First version number printed by " --version". +binary_version() { + "$1" --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -1 +} + +# True when $2 is a strictly newer version than $1. +version_newer() { + [[ $1 != "$2" && $(printf '%s\n%s\n' "$1" "$2" | sort -V | tail -1) == "$2" ]] +} + +# Copies of on PATH that mise does not manage: cargo installs, other +# pacman packages (e.g. jujutsu-git), npm globals, standalone installers. +# Omarchy's lazy mise stubs in ~/.local/bin and mise's own paths are skipped. +foreign_copies() { + local command="$1" path real + while IFS= read -r path; do + real=$(readlink -f "$path") + [[ $real == */mise/shims/* ]] && continue + [[ $real == */mise/installs/* && $real != */node_modules/* ]] && continue + grep -qs '^mise use -g' "$path" && continue + echo "$path" + done < <(type -ap "$command" | awk '!seen[$0]++') +} + +# Print the removal command for a foreign copy, or nothing when its source is +# unknown (then it is left alone). +removal_command() { + local path="$1" real owner crate + real=$(readlink -f "$path") + + if owner=$(pacman -Qoq "$path" 2>/dev/null); then + echo "sudo pacman -Rns --noconfirm $owner" + elif [[ $path == "$HOME/.cargo/bin/"* ]]; then + crate=$(cargo install --list 2>/dev/null | + awk -v bin="$(basename "$path")" '/^[^ ]/{c=$1} $1==bin && /^ /{print c}') + if [[ -n $crate ]]; then + echo "cargo uninstall $crate" + else + echo "rm -f $path" # standalone installer, e.g. uv's + fi + elif [[ $real =~ /lib/node_modules/((@[^/]+/)?[^/]+)/ ]]; then + echo "$(dirname "$path")/npm uninstall -g ${BASH_REMATCH[1]}" + fi +} + +# Offer to remove copies of a mise-managed tool that are older than the +# version mise would install. Each removal gets its own summary row. +replace_foreign_copies() { + local command="$1" target="$2" latest path version how + latest=$(mise latest "$target" 2>/dev/null) + [[ -n $latest ]] || return + + while IFS= read -r path; do + [[ -n $path ]] || continue + version=$(binary_version "$path") + how=$(removal_command "$path") + local row="$command (old: $path)" + + if [[ -z $how ]]; then + note "$path ($version): unknown source, left alone" + record "$row" kept yes + elif [[ -n $version ]] && version_newer "$version" "$latest"; then + if confirm "Remove older $command $version at $path ($how) in favour of $latest?"; then + # shellcheck disable=SC2086 # $how is a command line built above + run $how + record_action "$row" removed "[[ ! -e '$path' ]]" + else + record "$row" kept yes + fi + else + note "$path ($version) is not older than $latest, left alone" + record "$row" kept yes + fi + done < <(foreign_copies "$command") +} + +# uv from PATH, or through mise right after it was installed there. A dry run +# never reaches for mise, since `mise x` installs missing tools. +uv_cmd() { + if command -v uv &>/dev/null; then + uv "$@" + elif ! $DRY_RUN; then + mise x uv -- uv "$@" + else + return 1 + fi +} + +install_rustup() { + local item="$1" + if pacman -Qq rustup &>/dev/null; then + note "rustup already installed" + elif pacman -Qq rust &>/dev/null; then + if ! confirm "Replace the 'rust' package with rustup? (rustup then downloads the stable toolchain)"; then + record "$item" kept yes + return + fi + # rustup provides rust/cargo, so skipping dependency checks is safe here. + run sudo pacman -Rdd --noconfirm rust + run sudo pacman -S --noconfirm rustup + else + run sudo pacman -S --noconfirm rustup + fi + + run rustup default stable + run rustup component add "${RUST_COMPONENTS[@]}" + record_action "$item" installed \ + "pacman -Qq rustup &>/dev/null && rustup component list --installed | grep -q '^clippy'" +} + +install_item() { + local item group method target command + IFS='|' read -r item group method target command <<<"$1" + + case "$method" in + pacman | aur) + if pacman -Qq "$target" &>/dev/null; then + record "$item" kept yes + return + fi + if [[ $method == aur ]]; then + run omarchy-pkg-aur-add "$target" + else + run omarchy-pkg-add "$target" + fi + record_action "$item" installed "pacman -Qq '$target' &>/dev/null" + ;; + mise) + replace_foreign_copies "$command" "$target" + if mise ls --global --installed "$target" 2>/dev/null | grep -q .; then + run mise up --quiet "$target" + record "$item" kept yes + return + fi + run mise use -g --quiet "$target" + record_action "$item" installed "mise which '$command' &>/dev/null" + ;; + uvtool) + if uv_cmd tool list 2>/dev/null | grep -q "^$target "; then + record "$item" kept yes + return + fi + run uv_cmd tool install "$target" + record_action "$item" installed "uv_cmd tool list 2>/dev/null | grep -q '^$target '" + ;; + rustup) + install_rustup "$item" + ;; + esac +} + +step_add() { + info "Step 2 - Add desktop, system and developer tools" + + local options=() entry item group + for entry in "${CATALOGUE[@]}"; do + IFS='|' read -r item group _ <<<"$entry" + options+=("$group: $item") + done + + local selection + selection=$(choose "Select items to install (space to toggle, enter to confirm)" all "${options[@]}") + + for entry in "${CATALOGUE[@]}"; do + IFS='|' read -r item group _ <<<"$entry" + if grep -qxF "$group: $item" <<<"$selection"; then + info "$item" + install_item "$entry" + else + record "$item" kept yes + fi + done +} + +# --------------------------------------------------------------------------- +# Main +# --------------------------------------------------------------------------- + +print_summary() { + echo + info "Summary$($DRY_RUN && echo ' (dry run - nothing was changed)')" + { + printf 'item\tstatus\taction verified\n' + printf '%s\n' "${SUMMARY[@]}" + } | column -t -s $'\t' +} + +main() { + case "${1:-}" in + --dry-run) DRY_RUN=true ;; + "") ;; + *) echo "Usage: $0 [--dry-run]" >&2; exit 2 ;; + esac + + for tool in gum mise omarchy-pkg-add omarchy-webapp-remove; do + command -v "$tool" &>/dev/null || { echo "Missing $tool - is this Omarchy 4?" >&2; exit 1; } + done + + if ! $INTERACTIVE && ! $DRY_RUN; then + echo "No terminal: run interactively, or use --dry-run." >&2 + exit 1 + fi + + $DRY_RUN && warn "Dry run: nothing will be changed." + if ! $DRY_RUN && ! sudo -v; then + echo "sudo is required." >&2 + exit 1 + fi + + confirm "Step 1: remove preinstalled apps and web apps?" && step_remove + confirm "Step 2: install desktop, system and developer tools?" && step_add + + print_summary +} + +trap 'echo; echo "Cancelled"; print_summary; exit 1' INT + +main "$@" diff --git a/webapp-cleaner.sh b/webapp-cleaner.sh deleted file mode 100644 index 5c53bf1..0000000 --- a/webapp-cleaner.sh +++ /dev/null @@ -1,1159 +0,0 @@ -#!/bin/bash - -# Omarchy Cleaner - Remove unwanted default applications from Omarchy -# Enhanced with gum for a better TUI experience - -# Version -VERSION="2.0" - -# Configuration -BINDINGS_FILE="$HOME/.config/hypr/bindings.conf" -REMOVE_BINDINGS=false - -# App -# List from: https://github.com/basecamp/omarchy/blob/master/install/packages.sh -DEFAULT_APPS=( - # Packages offered for removal - "1password-beta" - "1password-cli" -# "kdenlive" # videa clips edditing -# "libreoffice" # standard MS office replacement -# "localsend" # open souurce cross-platform file sharing -# "obs-studio" # screencasting and live streaming -# "obsidian" # note taking based on markdown - "omarchy-chromium" # only libreoffice - "signal-desktop" # signal desktop app - "spotify" # you so not use it to listen music -# "xournalpp" # handwritten notes usefull when meeting - # you use different, classic docker setup for now you should keep it -# "docker" -# "docker-buildx" -# "docker-compose" - - # Uncomment to include in removal list - # "asdcontrol-git" - # "alacritty" - # "avahi" - # "bash-completion" - # "bat" - # "blueberry" - # "brightnessctl" - # "btop" - # "cargo" - # "clang" - # "cups" - # "cups-browsed" - # "cups-filters" - # "cups-pdf" - # "dust" - # "evince" - # "eza" - # "fastfetch" - # "fcitx5" - # "fcitx5-gtk" - # "fcitx5-qt" - # "fd" - # "ffmpegthumbnailer" - # "fontconfig" - # "fzf" - # "gcc14" - # "github-cli" - # "gnome-calculator" - # "gnome-keyring" - # "gnome-themes-extra" - # "gum" - # "gvfs-mtp" - # "gvfs-smb" - # "hypridle" - # "hyprland" - # "hyprland-qtutils" - # "hyprlock" - # "hyprpicker" - # "hyprshot" - # "hyprsunset" - # "imagemagick" - # "impala" - # "imv" - # "inetutils" - # "iwd" - # "jq" - # "kvantum-qt5" - # "lazydocker" - # "lazygit" - # "less" - # "libyaml" - # "libqalculate" - # "llvm" - # "luarocks" - # "mako" - # "man" - # "mariadb-libs" - # "mise" - # "mpv" - # "nautilus" - # "noto-fonts" - # "noto-fonts-cjk" - # "noto-fonts-emoji" - # "noto-fonts-extra" - # "nss-mdns" - # "omarchy-lazyvim" - # "nvim" - # "pamixer" - # "pinta" - # "playerctl" - # "plocate" - # "plymouth" - # "polkit-gnome" - # "postgresql-libs" - # "power-profiles-daemon" - # "python-gobject" - # "python-poetry-core" - # "python-terminaltexteffects" - # "qt5-wayland" - # "ripgrep" - # "satty" - # "slurp" - # "starship" - # "sushi" - # "swaybg" - # "swayosd" - # "system-config-printer" - # "tldr" - # "tree-sitter-cli" - # "ttf-cascadia-mono-nerd" - # "ttf-ia-writer" - # "ttf-jetbrains-mono-nerd" - # "typora" - # "tzupdate" - # "ufw" - # "ufw-docker" - # "unzip" - # "uwsm" - # "walker-bin" - # "waybar" - # "wf-recorder" - # "whois" - # "wireless-regdb" - # "wiremix" - # "wireplumber" - # "wl-clip-persist" - # "wl-clipboard" - # "wl-screenrec" - # "woff2-font-awesome" - # "xdg-desktop-portal-gtk" - # "xdg-desktop-portal-hyprland" - # "xmlstarlet" - # "yaru-icon-theme" - # "yay" - # "zoxide" -) - -# Webapps -# List from: https://github.com/basecamp/omarchy/blob/master/install/packaging/webapps.sh -DEFAULT_WEBAPPS=( - "HEY" - "Basecamp" - "WhatsApp" - "Google Photos" - "Google Contacts" - "Google Messages" - "ChatGPT" - "YouTube" - "GitHub" - "X" - "Figma" - "Discord" - "Zoom" -) - -# Function to check if package is installed -is_package_installed() { - local package="$1" - pacman -Qi "$package" &>/dev/null - return $? -} - -# Function to check if webapp is installed -is_webapp_installed() { - local webapp="$1" - # Check if .desktop file exists for the webapp - local desktop_file="$HOME/.local/share/applications/$webapp.desktop" - [[ -f "$desktop_file" ]] - return $? -} - -# Function to get list of installed packages from our removal list -get_installed_packages() { - for app in "${DEFAULT_APPS[@]}"; do - if is_package_installed "$app"; then - echo "$app" - fi - done -} - -# Function to get list of installed webapps from our removal list -get_installed_webapps() { - for webapp in "${DEFAULT_WEBAPPS[@]}"; do - if is_webapp_installed "$webapp"; then - echo "$webapp" - fi - done -} - -# Function to find keyboard bindings for an app/webapp -find_app_bindings() { - local app_name="$1" - local bindings=() - - if [[ ! -f "$BINDINGS_FILE" ]]; then - echo "" - return - fi - - # Convert app name to lowercase for case-insensitive matching - local app_lower=$(echo "$app_name" | tr '[:upper:]' '[:lower:]') - - # Define webapp URL patterns for known webapps - local webapp_domains="" - case "$app_lower" in - "hey") - webapp_domains="app.hey.com|hey.com" - ;; - "basecamp") - webapp_domains="basecamp.com|3.basecamp.com" - ;; - "whatsapp") - webapp_domains="web.whatsapp.com|whatsapp.com" - ;; - "google photos") - webapp_domains="photos.google.com" - ;; - "google contacts") - webapp_domains="contacts.google.com" - ;; - "google messages") - webapp_domains="messages.google.com" - ;; - "chatgpt") - webapp_domains="chatgpt.com|chat.openai.com" - ;; - "youtube") - webapp_domains="youtube.com|youtu.be" - ;; - "github") - webapp_domains="github.com" - ;; - "x") - webapp_domains="x.com|twitter.com" - ;; - "figma") - webapp_domains="figma.com" - ;; - "discord") - webapp_domains="discord.com|discord.gg" - ;; - "zoom") - webapp_domains="zoom.us|zoom.com" - ;; - esac - - # Read the bindings file and find matching lines - while IFS= read -r line; do - # Skip comments and empty lines - [[ "$line" =~ ^[[:space:]]*# ]] && continue - [[ -z "${line// }" ]] && continue - - # Check if this is a bindd line - if [[ "$line" =~ ^bindd[[:space:]]*= ]]; then - local line_lower=$(echo "$line" | tr '[:upper:]' '[:lower:]') - - # Check for app matches in various formats - # Direct app name match (e.g., "spotify", "obsidian", "signal-desktop") - if [[ "$line_lower" =~ uwsm[[:space:]]+app[[:space:]]+--[[:space:]]+$app_lower([[:space:]]|$) ]]; then - bindings+=("$line") - # Terminal app match (e.g., "btop", "lazydocker", "nvim") - elif [[ "$line_lower" =~ \$terminal[[:space:]]+-e[[:space:]]+$app_lower([[:space:]]|$) ]]; then - bindings+=("$line") - # Webapp match - check by URL domain if defined - elif [[ "$line_lower" =~ omarchy-launch-webapp ]]; then - if [[ -n "$webapp_domains" ]]; then - # Extract URL from the line - if [[ "$line" =~ omarchy-launch-webapp[[:space:]]+\"([^\"]+)\" ]]; then - local url="${BASH_REMATCH[1]}" - # Check if URL matches any of the webapp domains - if [[ "$url" =~ ($webapp_domains) ]]; then - bindings+=("$line") - fi - fi - else - # Fallback to label matching for unknown webapps - if [[ "$line" =~ ,[[:space:]]*([^,]+),[[:space:]]*exec ]]; then - local label=$(echo "$line" | sed -n 's/.*,[[:space:]]*\([^,]*\),[[:space:]]*exec.*/\1/p' | xargs) - local label_lower=$(echo "$label" | tr '[:upper:]' '[:lower:]') - if [[ "$label_lower" == "$app_lower" ]]; then - bindings+=("$line") - fi - fi - fi - # Docker special case - elif [[ "$app_lower" == "docker" ]] && [[ "$line_lower" =~ (docker|lazydocker) ]]; then - bindings+=("$line") - # 1password special cases - elif [[ "$app_lower" == "1password-beta" || "$app_lower" == "1password-cli" ]] && [[ "$line_lower" =~ 1password ]]; then - bindings+=("$line") - # Nautilus (File manager) - elif [[ "$app_lower" == "nautilus" ]] && [[ "$line_lower" =~ nautilus ]]; then - bindings+=("$line") - fi - fi - done < "$BINDINGS_FILE" - - # Return unique bindings - printf '%s\n' "${bindings[@]}" | sort -u -} - -# Function to remove bindings from the config file -remove_bindings_from_file() { - local bindings_to_remove=("$@") - - if [[ ${#bindings_to_remove[@]} -eq 0 ]]; then - return 0 - fi - - if [[ ! -f "$BINDINGS_FILE" ]]; then - gum log --level warn "Bindings file not found at $BINDINGS_FILE" - return 1 - fi - - # Create backup - local backup_file="${BINDINGS_FILE}.backup.$(date +%Y%m%d_%H%M%S)" - cp "$BINDINGS_FILE" "$backup_file" - gum log --level info "Created backup: $backup_file" - - # Create temporary file - local temp_file=$(mktemp) - local removed_count=0 - - # Process the file line by line - while IFS= read -r line; do - local should_remove=false - - # Check if this line should be removed - for binding in "${bindings_to_remove[@]}"; do - if [[ "$line" == "$binding" ]]; then - should_remove=true - ((removed_count++)) - break - fi - done - - # Write line to temp file if not removing - if [[ "$should_remove" == false ]]; then - echo "$line" >> "$temp_file" - fi - done < "$BINDINGS_FILE" - - # Replace original file with temp file - mv "$temp_file" "$BINDINGS_FILE" - - gum log --level info "✓ Removed $removed_count keyboard binding(s)" - return 0 -} - - -# Enhanced selection menu using gum with integrated keyboard toggle -enhanced_select_packages() { - local installed_packages=("$@") - local all_items=() - local item_types=() - local display_items=() - local bindings_found=() - - # Parse arguments - first determine where packages end and webapps begin - local separator_index=-1 - for i in "${!installed_packages[@]}"; do - if [[ "${installed_packages[$i]}" == "--webapps--" ]]; then - separator_index=$i - break - fi - done - - if [[ $separator_index -ge 0 ]]; then - # Split into packages and webapps - for ((i=0; i/dev/null 2>&1"; then - gum log --level info "✓ Removed: $webapp" - removed_webapps+=("$webapp") - else - gum log --level error "✗ Failed: $webapp" - failed_webapps+=("$webapp") - fi - - # Show progress bar - local percentage=$(( (current * 100) / total )) - local filled=$(( percentage / 5 )) - local empty=$(( (100 - percentage) / 5 )) - - printf "Progress: " - printf '\033[92m█%.0s\033[0m' $(seq 1 $filled) - printf '\033[90m░%.0s\033[0m' $(seq 1 $empty) - printf " %d%% (%d/%d)\n" "$percentage" "$current" "$total" - echo "" - done - - # Summary for webapps - echo "" - if [[ ${#removed_webapps[@]} -gt 0 ]]; then - gum style --foreground 82 "Successfully removed: ${removed_webapps[*]}" - fi - if [[ ${#failed_webapps[@]} -gt 0 ]]; then - gum style --foreground 214 "Could not remove: ${failed_webapps[*]}" - fi - - # Return the number of failed webapps as exit code - return ${#failed_webapps[@]} -} - -# Function to remove packages -remove_packages() { - local packages=("$@") - local failed_packages=() - local removed_packages=() - - if [[ ${#packages[@]} -eq 0 ]]; then - return 0 - fi - - echo "" - gum style \ - --foreground 39 \ - --bold \ - "📦 Removing ${#packages[@]} package(s)..." - echo "" - - # Ensure we have sudo credentials before starting - if ! sudo -n true 2>/dev/null; then - gum style --foreground 214 "🔐 Administrator privileges required for package removal" - if ! sudo true; then - gum log --level error "Failed to obtain sudo privileges" - return 1 - fi - echo "" - fi - - local current=0 - local total=${#packages[@]} - - for pkg in "${packages[@]}"; do - ((current++)) - - # Show current progress - gum style --foreground 51 "[$current/$total] Processing: $pkg" - - if gum spin --spinner dot --title "Removing $pkg..." -- bash -c "sudo pacman -Rns --noconfirm '$pkg' 2>/dev/null"; then - gum log --level info "✓ Removed: $pkg" - removed_packages+=("$pkg") - else - gum log --level warn "✗ Failed: $pkg (may have dependencies)" - failed_packages+=("$pkg") - fi - - # Show progress bar - local percentage=$(( (current * 100) / total )) - local filled=$(( percentage / 5 )) - local empty=$(( (100 - percentage) / 5 )) - - printf "Progress: " - printf '\033[92m█%.0s\033[0m' $(seq 1 $filled) - printf '\033[90m░%.0s\033[0m' $(seq 1 $empty) - printf " %d%% (%d/%d)\n" "$percentage" "$current" "$total" - echo "" - done - - # Summary for packages - echo "" - if [[ ${#removed_packages[@]} -gt 0 ]]; then - gum style --foreground 82 "Successfully removed: ${removed_packages[*]}" - fi - if [[ ${#failed_packages[@]} -gt 0 ]]; then - gum style --foreground 214 "Could not remove: ${failed_packages[*]}" - fi - - # Return the number of failed packages as exit code - return ${#failed_packages[@]} -} - -# Function to remove both packages and webapps -remove_items() { - local packages=("$@") - local webapps=() - local all_bindings_to_remove=() - - # Global success tracking - local total_attempted=0 - local total_failed=0 - - # Parse arguments - find separator - local separator_index=-1 - for i in "${!packages[@]}"; do - if [[ "${packages[$i]}" == "--webapps--" ]]; then - separator_index=$i - break - fi - done - - if [[ $separator_index -ge 0 ]]; then - # Split into packages and webapps arrays - local pkg_array=() - local webapp_array=() - - for ((i=0; i