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
This commit is contained in:
parent
0baa39f13f
commit
e237c7d22a
111
README.md
111
README.md
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
- [Overview](#overview)
|
- [Overview](#overview)
|
||||||
- [App cleanup](#app-cleanup)
|
- [Configurator](#configurator)
|
||||||
- [Packages](#packages)
|
- [Packages](#packages)
|
||||||
- [Default browser](#default-browser)
|
- [Default browser](#default-browser)
|
||||||
- [NVIDIA](#nvidia)
|
- [NVIDIA](#nvidia)
|
||||||
@ -36,22 +36,101 @@ and the shell prompt.
|
|||||||
> Commands below are recorded as run on the author's machine. Verify package
|
> Commands below are recorded as run on the author's machine. Verify package
|
||||||
> names and paths against your own hardware before applying.
|
> names and paths against your own hardware before applying.
|
||||||
|
|
||||||
## App cleanup
|
Quick start:
|
||||||
|
|
||||||
Omarchy ships several web apps that may not fit your needs. The original
|
|
||||||
selector script comes from `omarchy-cleaner`:
|
|
||||||
|
|
||||||
```bash
|
```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
|
## Configurator
|
||||||
> and read it first if you are unsure what it removes.
|
|
||||||
|
|
||||||
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
|
||||||
bash webapp-cleaner.sh
|
./config_installer.sh --dry-run < /dev/null
|
||||||
```
|
```
|
||||||
|
|
||||||
## Packages
|
## Packages
|
||||||
@ -68,14 +147,8 @@ sudo pacman -S fcitx5-config-qt fcitx5-configtool fcitx5-gtk
|
|||||||
|
|
||||||
## Default browser
|
## Default browser
|
||||||
|
|
||||||
Install the `librewolf-bin` binary package — it is noticeably faster to set up
|
LibreWolf is installed by [step 2](#step-2--add). Make it the default browser
|
||||||
than building `librewolf` from source:
|
so it matches the assigned keybinding:
|
||||||
|
|
||||||
```bash
|
|
||||||
yay -S librewolf-bin
|
|
||||||
```
|
|
||||||
|
|
||||||
Make LibreWolf the default browser so it matches the assigned keybinding:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
echo 'export BROWSER=librewolf' >> /home/$USER/.config/uwsm/default
|
echo 'export BROWSER=librewolf' >> /home/$USER/.config/uwsm/default
|
||||||
@ -211,7 +284,7 @@ cp src/starship.toml ~/.config/
|
|||||||
## Repository layout
|
## 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/
|
src/
|
||||||
starship.toml # Starship shell-prompt config (copy to ~/.config/)
|
starship.toml # Starship shell-prompt config (copy to ~/.config/)
|
||||||
LICENSE # MIT
|
LICENSE # MIT
|
||||||
|
|||||||
565
config_installer.sh
Executable file
565
config_installer.sh
Executable file
@ -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=() # "item<TAB>status<TAB>verified"
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# 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 <header> <preselect: all|none> <options...>; 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 "KEY<TAB>Label". 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 "<binary> --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 <command> 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 "$@"
|
||||||
1159
webapp-cleaner.sh
1159
webapp-cleaner.sh
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user