diff --git a/agents/skills/install-scripts.md b/agents/skills/install-scripts.md index 999a6e9ca0a7..aa993e5e54bd 100644 --- a/agents/skills/install-scripts.md +++ b/agents/skills/install-scripts.md @@ -13,6 +13,7 @@ commands and reusable setup leaves: - use `$OMARCHY_INSTALL` and `$OMARCHY_PATH` instead of hard-coded Omarchy paths. - keep root-scoped hardware setup under `install/hardware/` and orchestrate it through `install/hardware/all.sh`. - keep every per-user setup leaf under `install/user/` (including `install/user/hardware/` and `install/user/first-run/`) so it is clear what must run for each user. +- The base install supplies matching kernel headers before hardware setup. DKMS installers should install their driver packages and assume the headers exist. - prefer helper commands for package and command checks where available. Raw `command -v`, `pacman`, and `pacman-key` are acceptable in package-helper diff --git a/bin/omarchy-capture-screenrecording b/bin/omarchy-capture-screenrecording index d57b26fee50f..0c4c5494c952 100755 --- a/bin/omarchy-capture-screenrecording +++ b/bin/omarchy-capture-screenrecording @@ -15,8 +15,9 @@ # start. # # Env: OMARCHY_SCREENRECORD_DEBUG=true appends gpu-screen-recorder's stderr (and -# the picker target it was launched with) to /tmp/omarchy-screenrecord.log so -# users can attach a log when reporting capture failures. +# the picker target it was launched with) to +# $XDG_RUNTIME_DIR/omarchy-screenrecord.log so users can attach a log when +# reporting capture failures. [[ -f ~/.config/user-dirs.dirs ]] && source ~/.config/user-dirs.dirs OUTPUT_DIR="${OMARCHY_SCREENRECORD_DIR:-${XDG_VIDEOS_DIR:-$HOME/Videos}}" @@ -34,9 +35,18 @@ WEBCAM_SIZE="medium" RESOLUTION="" FULLSCREEN="false" STOP_RECORDING="false" -RECORDING_FILE="/tmp/omarchy-screenrecord-filename" -REGION_FILE="${XDG_RUNTIME_DIR:-/tmp}/omarchy-screenrecord-region" -LOG_FILE=$([[ ${OMARCHY_SCREENRECORD_DEBUG:-false} == "true" ]] && echo "/tmp/omarchy-screenrecord.log" || echo "/dev/null") +# Both of these live in the per-user runtime directory, which is 0700. What +# RECORDING_FILE holds is read back on stop and used as a path -- ffmpeg writes +# beside it, `mv` replaces it, and `rm -f` deletes its preview -- so a name in +# world-writable /tmp is a name any other local account can create first and +# then point wherever it likes. The debug log carries the recorder's stderr and +# the picked geometry, which is nobody else's business either. Fall back to +# the state directory when there is no session runtime dir -- :-/tmp would put +# both files back at the fixed names this comment describes. +RUNTIME_DIR="${XDG_RUNTIME_DIR:-${XDG_STATE_HOME:-$HOME/.local/state}/omarchy}" +RECORDING_FILE="$RUNTIME_DIR/omarchy-screenrecord-filename" +REGION_FILE="$RUNTIME_DIR/omarchy-screenrecord-region" +LOG_FILE=$([[ ${OMARCHY_SCREENRECORD_DEBUG:-false} == "true" ]] && echo "$RUNTIME_DIR/omarchy-screenrecord.log" || echo "/dev/null") for arg in "$@"; do case "$arg" in @@ -144,6 +154,11 @@ select_capture_target() { } start_screenrecording() { + mkdir -p "$RUNTIME_DIR" || return 1 + # XDG_STATE_HOME may be outside a private home; protect existing fallbacks too. + if [[ -z ${XDG_RUNTIME_DIR:-} ]]; then + chmod 700 "$RUNTIME_DIR" || return 1 + fi local capture_args=() local target diff --git a/bin/omarchy-capture-webcam-resize b/bin/omarchy-capture-webcam-resize index cde61e087cfa..3c9d12155846 100755 --- a/bin/omarchy-capture-webcam-resize +++ b/bin/omarchy-capture-webcam-resize @@ -8,7 +8,10 @@ set -euo pipefail readonly MARGIN=40 -readonly REGION_FILE="${XDG_RUNTIME_DIR:-/tmp}/omarchy-screenrecord-region" +# Has to resolve to whatever omarchy-capture-screenrecording writes, fallback +# included, or a recording without a session runtime dir anchors the camera to +# the whole monitor instead of the region it recorded. +readonly REGION_FILE="${XDG_RUNTIME_DIR:-${XDG_STATE_HOME:-$HOME/.local/state}/omarchy}/omarchy-screenrecord-region" usage() { echo "Usage: omarchy-capture-webcam-resize " >&2 diff --git a/bin/omarchy-default-agent b/bin/omarchy-default-agent index 239bf74b599f..1504f6617d98 100755 --- a/bin/omarchy-default-agent +++ b/bin/omarchy-default-agent @@ -108,6 +108,10 @@ else fi fi +if [[ $agent == "claude" ]]; then + omarchy-install-chromium-claude 2>/dev/null || true +fi + mkdir -p "$(dirname "$agent_file")" printf '%s\n' "$agent" >"$agent_file" diff --git a/bin/omarchy-install-chromium-claude b/bin/omarchy-install-chromium-claude new file mode 100755 index 000000000000..df3382712923 --- /dev/null +++ b/bin/omarchy-install-chromium-claude @@ -0,0 +1,43 @@ +#!/bin/bash + +# omarchy:summary=Install the Claude extension for Chromium-based browsers +# omarchy:requires-sudo=true + +set -euo pipefail + +if (( EUID == 0 )); then + export PATH=/usr/bin:/bin +fi + +EXTENSION_ID="fcoeoabgfenejglbffodgkkbkcdhcgfn" +EXTENSION_JSON='{ "external_update_url": "https://clients2.google.com/service/update2/crx" }' +PACKAGED_PATH=/usr/bin/omarchy-install-chromium-claude + +# Brave and Brave Origin share Chromium's external extension directory. +# Seed all supported browsers, including those installed after choosing Claude. +EXTENSION_DIRS=( + /usr/share/chromium/extensions + /usr/share/google-chrome/extensions + /usr/share/microsoft-edge/extensions +) + +installed=true +for dir in "${EXTENSION_DIRS[@]}"; do + if [[ ! -f $dir/$EXTENSION_ID.json ]] || [[ $(cat "$dir/$EXTENSION_ID.json") != "$EXTENSION_JSON" ]]; then + installed=false + fi +done + +if [[ $installed == "true" ]]; then + exit 0 +fi + +if (( EUID == 0 )); then + for dir in "${EXTENSION_DIRS[@]}"; do + printf '%s\n' "$EXTENSION_JSON" | install -D -m 0644 /dev/stdin "$dir/$EXTENSION_ID.json" + done +elif [[ -t 0 ]]; then + exec sudo "$PACKAGED_PATH" +else + exec pkexec "$PACKAGED_PATH" +fi diff --git a/bin/omarchy-install-gaming-xbox-controllers b/bin/omarchy-install-gaming-xbox-controllers index f4134f767fdf..f2cda4e7c6c4 100755 --- a/bin/omarchy-install-gaming-xbox-controllers +++ b/bin/omarchy-install-gaming-xbox-controllers @@ -10,7 +10,7 @@ set -e echo "Installing Xbox controller Bluetooth support..." # Install xpadneo to ensure controllers work out of the box -omarchy-pkg-add linux-headers xpadneo-dkms +omarchy-pkg-add xpadneo-dkms # Prevent xpad/xpadneo driver conflict echo blacklist xpad | sudo tee /etc/modprobe.d/blacklist-xpad.conf >/dev/null diff --git a/bin/omarchy-update-keyring b/bin/omarchy-update-keyring index d561e22a2773..3a1c1c17692e 100755 --- a/bin/omarchy-update-keyring +++ b/bin/omarchy-update-keyring @@ -3,6 +3,11 @@ # omarchy:summary=Ensure the Omarchy and Arch keyring packages are installed and populated # omarchy:requires-sudo=true +# omarchy-update runs this under set -e as a trusted pre-step, so a failed recv +# or a broken keyring has to stop this script here, not surface later as +# signature errors in the middle of the main transaction. +set -euo pipefail + if omarchy-pkg-missing omarchy-keyring || ! sudo pacman-key --list-keys 40DFB630FF42BCFFB047046CF0134EE680CAC571 &>/dev/null; then sudo pacman-key --recv-keys 40DFB630FF42BCFFB047046CF0134EE680CAC571 --keyserver keys.openpgp.org sudo pacman-key --lsign-key 40DFB630FF42BCFFB047046CF0134EE680CAC571 @@ -19,4 +24,8 @@ fi # Always reinstall, as the keyring can be updated without a package version bump. echo -e "\e[32m\nUpdate Arch signing keys\e[0m" sudo pacman -Sy --noconfirm archlinux-keyring >/dev/null 2> >(grep -vE '^warning: archlinux-keyring-[^ ]+ is up to date -- reinstalling$' >&2) + +# Say "correct" only once the key verifiably is: before the failure checks +# above, a failed recv or reinstall still ended here with exit 0. +sudo pacman-key --list-keys 40DFB630FF42BCFFB047046CF0134EE680CAC571 >/dev/null echo "Keys are correct" diff --git a/bin/omarchy-windows-vm b/bin/omarchy-windows-vm index f672ed7eee1d..6c8204da905a 100755 --- a/bin/omarchy-windows-vm +++ b/bin/omarchy-windows-vm @@ -1457,8 +1457,31 @@ To stop: omarchy-windows-vm stop" fi # If scale is less than 130%, don't set any scale (use default 100) - # Connect with RDP in fullscreen (auto-detects resolution) - xfreerdp3 /u:"$WIN_USER" /p:"$WIN_PASS" /v:127.0.0.1:3389 -grab-keyboard /sound /microphone /clipboard /cert:ignore /title:"Windows VM - Omarchy" /dynamic-resolution /gfx:AVC444 /floatbar:sticky:off,default:visible,show:fullscreen $RDP_SCALE + RDP_ARGS=( + "/u:$WIN_USER" + "/p:$WIN_PASS" + /v:127.0.0.1:3389 + -grab-keyboard + /sound + /microphone + /clipboard + /cert:ignore + "/title:Windows VM - Omarchy" + /dynamic-resolution + /gfx:AVC444 + /floatbar:sticky:off,default:visible,show:fullscreen + ) + if [[ -n $RDP_SCALE ]]; then + RDP_ARGS+=("$RDP_SCALE") + fi + + # Connect with RDP in fullscreen (auto-detects resolution). The arguments go + # in over stdin rather than on the command line: /proc//cmdline is + # world-readable, so passing the VM password as /p:"$WIN_PASS" would show it + # to every other user on the machine for as long as the session is open. + # /args-from must stay the only argument here — FreeRDP rejects it outright + # when it is combined with any other, so new flags belong in RDP_ARGS above. + printf '%s\n' "${RDP_ARGS[@]}" | xfreerdp3 /args-from:stdin # After RDP closes, stop the container unless --keep-alive was specified if [[ $KEEP_ALIVE = "false" ]]; then diff --git a/default/agents/skills/omarchy/capture.md b/default/agents/skills/omarchy/capture.md index 41a52b6cd205..621bc2989f61 100644 --- a/default/agents/skills/omarchy/capture.md +++ b/default/agents/skills/omarchy/capture.md @@ -33,7 +33,7 @@ Recordings land in the configured Videos directory (override with `omarchy capture webcam resize `. If recording fails to start, rerun with `OMARCHY_SCREENRECORD_DEBUG=true` to -collect a log at `/tmp/omarchy-screenrecord.log` worth attaching to a bug +collect a log at `$XDG_RUNTIME_DIR/omarchy-screenrecord.log` (or `${XDG_STATE_HOME:-$HOME/.local/state}/omarchy/omarchy-screenrecord.log` without a session runtime directory) worth attaching to a bug report. ## Text Capture (OCR) diff --git a/default/agents/skills/omarchy/contributing.md b/default/agents/skills/omarchy/contributing.md index b5fd05335d33..c76c12d61f88 100644 --- a/default/agents/skills/omarchy/contributing.md +++ b/default/agents/skills/omarchy/contributing.md @@ -38,7 +38,7 @@ drag-and-drop in the web form, so save the capture and hand the user the file path to attach (`gh` cannot upload media). For screen-recording failures specifically, rerun with -`OMARCHY_SCREENRECORD_DEBUG=true` and attach `/tmp/omarchy-screenrecord.log`. +`OMARCHY_SCREENRECORD_DEBUG=true` and attach `$XDG_RUNTIME_DIR/omarchy-screenrecord.log` (or `${XDG_STATE_HOME:-$HOME/.local/state}/omarchy/omarchy-screenrecord.log` without a session runtime directory). File the issue with `gh` when available: diff --git a/etc/sysctl.d/99-omarchy-sysctl.conf b/etc/sysctl.d/99-omarchy-sysctl.conf index 1cce6d7fcc08..dac0fb2b215d 100644 --- a/etc/sysctl.d/99-omarchy-sysctl.conf +++ b/etc/sysctl.d/99-omarchy-sysctl.conf @@ -1,6 +1,12 @@ # Solve common flakiness with SSH (MTU discovery on flaky links). net.ipv4.tcp_mtu_probing=1 +# BBR estimates bottleneck bandwidth and minimum RTT and paces to them, where +# cubic keeps pushing until packets drop. That cuts queueing latency +# (bufferbloat) on fast links. fq is the qdisc BBR is built to pace through. +net.core.default_qdisc=fq +net.ipv4.tcp_congestion_control=bbr + # Tune reclaim for swap on zram, which is orders of magnitude faster than the # disk swapfile these defaults assume. diff --git a/install/hardware/fix-bcm43xx.sh b/install/hardware/fix-bcm43xx.sh index 6b7e5648f1f0..0f9cf474a5be 100644 --- a/install/hardware/fix-bcm43xx.sh +++ b/install/hardware/fix-bcm43xx.sh @@ -6,5 +6,5 @@ pci_info=$(lspci -nn) if (echo "$pci_info" | grep -q "14e4:43a0" || echo "$pci_info" | grep -q "14e4:4331"); then echo "BCM4360 / BCM4331 detected" - omarchy-pkg-add broadcom-wl-dkms linux-headers + omarchy-pkg-add broadcom-wl-dkms fi diff --git a/install/hardware/fix-elgato-camlink-4k.sh b/install/hardware/fix-elgato-camlink-4k.sh index 274076cef57c..9ae9e343d47c 100644 --- a/install/hardware/fix-elgato-camlink-4k.sh +++ b/install/hardware/fix-elgato-camlink-4k.sh @@ -4,8 +4,7 @@ # v4l2-relayd re-exposes it at 1280x720 under the same name. if omarchy-hw-elgato-camlink-4k; then - mapfile -t kernel_headers < <(pacman -Qqs '^linux(-zen|-lts|-hardened|-t2|-ptl|-omarchy(-bore|-ptl-novrr-mm)?)?$' | sed 's/$/-headers/') - omarchy-pkg-add "${kernel_headers[@]}" v4l2loopback-dkms v4l2loopback-utils v4l2-relayd + omarchy-pkg-add v4l2loopback-dkms v4l2loopback-utils v4l2-relayd sudo install -Dm644 "$OMARCHY_PATH/default/udev/elgato-camlink-4k.rules" /etc/udev/rules.d/71-elgato-camlink-4k.rules sudo install -Dm644 "$OMARCHY_PATH/default/v4l2-relayd/camlink.conf" /etc/v4l2-relayd.d/camlink.conf diff --git a/install/hardware/fix-tuxedo-backlight.sh b/install/hardware/fix-tuxedo-backlight.sh index 9644d310e612..7fb408e0d543 100644 --- a/install/hardware/fix-tuxedo-backlight.sh +++ b/install/hardware/fix-tuxedo-backlight.sh @@ -1,7 +1,7 @@ # Install Tuxedo drivers for keyboard backlighting on Tuxedo laptops and # compatible devices like the Slimbook Executive (Clevo/Tuxedo chassis). if cat /sys/class/dmi/id/sys_vendor 2>/dev/null | grep -qi "TUXEDO\|Slimbook"; then - omarchy-pkg-add linux-headers tuxedo-drivers-nocompatcheck-dkms + omarchy-pkg-add tuxedo-drivers-nocompatcheck-dkms # Blacklist the legacy clevo_xsm_wmi module which conflicts with the tuxedo-drivers # clevo_wmi module. When clevo_xsm_wmi loads first, it grabs the Clevo WMI GUIDs, diff --git a/install/hardware/fix-yt6801-ethernet-adapter.sh b/install/hardware/fix-yt6801-ethernet-adapter.sh index 34331a0fa883..f88a9cec624b 100644 --- a/install/hardware/fix-yt6801-ethernet-adapter.sh +++ b/install/hardware/fix-yt6801-ethernet-adapter.sh @@ -1,4 +1,4 @@ # Install drivers for Motorcomm YT6801 ethernet adapter used by the Slimbook Executive if lspci | grep -i "YT6801\|Motorcomm.*Ethernet"; then - omarchy-pkg-add linux-headers yt6801-dkms + omarchy-pkg-add yt6801-dkms fi diff --git a/install/hardware/nvidia.sh b/install/hardware/nvidia.sh index 48f62cd4b15a..1c36787b7705 100644 --- a/install/hardware/nvidia.sh +++ b/install/hardware/nvidia.sh @@ -1,8 +1,4 @@ if lspci | grep -qi 'nvidia'; then - # Check which kernel is installed and set appropriate headers package - KERNEL_PACKAGE=$(pacman -Qqs '^linux(-zen|-lts|-hardened|-t2|-ptl|-omarchy(-bore|-ptl-novrr-mm)?)?$' | head -1 || true) - [[ -n $KERNEL_PACKAGE ]] && omarchy-pkg-add "$KERNEL_PACKAGE-headers" - if omarchy-hw-nvidia-gsp; then PACKAGES=(nvidia-open-dkms nvidia-utils lib32-nvidia-utils libva-nvidia-driver) elif omarchy-hw-nvidia-without-gsp; then diff --git a/install/user/mise-work.sh b/install/user/mise-work.sh index f77d5561e0e6..9ce5249fef0a 100644 --- a/install/user/mise-work.sh +++ b/install/user/mise-work.sh @@ -2,13 +2,6 @@ mkdir -p "$HOME/Work" mkdir -p "$HOME/Work/tries" -cat >"$HOME/Work/.mise.toml" <<'EOF' -[env] -_.path = "{{ cwd }}/bin" -EOF - -mise trust ~/Work/.mise.toml - # Offline installs unpack the Node tarball bundled by the ISO: from # /opt/packages in the ISO chroot, or from the copy staged in provisioning state when # omarchy-provision-owner finalizes the user at first boot. diff --git a/manual/17-ai.md b/manual/17-ai.md index 93edbf2d6c81..848016a8977c 100644 --- a/manual/17-ai.md +++ b/manual/17-ai.md @@ -26,6 +26,8 @@ To wrap an additional CLI the same way, run `omarchy-mise-install [com Pick your default agent with `omarchy default agent ` or under _Setup > Defaults > Agent_ in the Omarchy Menu (`Super + Space`). If the agent isn't installed yet, picking it installs it first. A fresh Omarchy will invite you to make this choice with a one-time notification. +Choosing Claude also attempts to set up its browser extension for Chromium, Chrome, Brave, Brave Origin, and Edge. The extension setup applies to all users and may ask for your system password; cancelling or a failed extension install still selects and launches Claude. Restart your browser, enable the extension if prompted, and sign in to Claude to finish connecting it. Run `/chrome` in Claude to check the connection. Firefox and Zen do not support this extension. If Claude was already your default before this setup was added, select it again to install the extension. + [Muse Code](https://dev.meta.ai) — Meta's `muse` — uses a preinstalled mise stub like the other agents. Picking it as the default installs Meta's official launcher through mise's HTTP backend. The launcher verifies and updates the native binary for your machine. Once you've chosen, `Super + Shift + Ctrl + A` launches the default agent in a dedicated terminal window (or brings up the picker if you haven't chosen yet). You can also launch it straight into a task with `omarchy agent prompt "Review this project"`. Agents launched this way run unattended in their respective don't-stop-to-ask modes, so be ready for them to actually do things! And since agents refuse to remember trust for your home directory, launches from `$HOME` start in `~/Work` instead. diff --git a/manual/19-shell-tools.md b/manual/19-shell-tools.md index 69965fdd4617..8252d795f95a 100644 --- a/manual/19-shell-tools.md +++ b/manual/19-shell-tools.md @@ -57,3 +57,5 @@ The full manual can be found via `man yt-dlp`. ## try [try](https://github.com/tobi/try) makes it easy to manage programming experiments with date-stamped directories. All experiments live in `~/Work/tries` and you can access them via `try`. + +Omarchy does not add a project's `bin/` directory to `PATH` automatically. Run trusted project-local tools with an explicit relative path, such as `bin/rails` or `./bin/dev`. diff --git a/migrations/1789095456.sh b/migrations/1789095456.sh new file mode 100644 index 000000000000..381557fc79b7 --- /dev/null +++ b/migrations/1789095456.sh @@ -0,0 +1,99 @@ +echo "Remove automatic project bin directories from PATH" + +work_dir="$HOME/Work" +mise_config="$work_dir/.mise.toml" +# install/user/mise-work.sh as shipped in Omarchy 4.0.3. +stock_sha="bd04f191d63bbde86920f44f76f0989fad980afc84e268e8474c201ec7149245" +cwd_bin='\{\{[[:space:]]*cwd[[:space:]]*\}\}/bin' +unsafe_path="^[[:space:]]*_[.]path[[:space:]]*=[[:space:]]*(\"$cwd_bin\"|'$cwd_bin')[[:space:]]*(#.*)?$" +env_section='^[[:space:]]*\[[[:space:]]*env[[:space:]]*\][[:space:]]*(#.*)?$' +any_section='^[[:space:]]*\[\[?.*\]\]?[[:space:]]*(#.*)?$' + +remove_empty_work_dir=false +if [[ ! -e $work_dir ]]; then + mkdir -p "$work_dir" + remove_empty_work_dir=true +fi + +was_ignored=false +if [[ -d $work_dir ]]; then + mise_state_dir=${MISE_STATE_DIR:-${XDG_STATE_HOME:-$HOME/.local/state}/mise} + ignored_configs_dir="$mise_state_dir/ignored-configs" + work_target=$(readlink -m "$work_dir") + config_path_target="$work_target/.mise.toml" + config_target=$(readlink -m "$mise_config") + + if [[ -d $ignored_configs_dir ]]; then + for ignored_entry in "$ignored_configs_dir"/*; do + [[ -L $ignored_entry ]] || continue + ignored_target=$(readlink "$ignored_entry") + if [[ $ignored_target == $work_target || $ignored_target == $config_path_target || $ignored_target == $config_target ]]; then + was_ignored=true + break + fi + done + fi + + if [[ $was_ignored == "false" ]]; then + # Normal Mise trust is recorded against the config-root directory, while + # paranoid trust is recorded against the file and its contents. Stage an + # empty, inert config when the legacy file is gone so either trust mode can + # resolve and revoke the original grant. + remove_empty_mise_config=false + if [[ ! -e $mise_config && ! -L $mise_config ]]; then + if (set -o noclobber; : >"$mise_config") 2>/dev/null; then + remove_empty_mise_config=true + fi + fi + + untrust_target="$work_dir" + if [[ -f $mise_config ]]; then + untrust_target="$mise_config" + fi + + if mise trust --untrust "$untrust_target"; then + : + else + if [[ $remove_empty_mise_config == "true" ]]; then + rm -f -- "$mise_config" + fi + exit 1 + fi + + if [[ $remove_empty_mise_config == "true" ]]; then + rm -f -- "$mise_config" + fi + fi +fi + +if [[ -f $mise_config ]]; then + if [[ ! -L $mise_config && $(sha256sum "$mise_config" | cut -d ' ' -f 1) == $stock_sha ]]; then + rm -f -- "$mise_config" + else + unsafe_env_paths=$(sed -n -E "\\%$env_section%,\\%$any_section% { \\%$unsafe_path%p; }" "$mise_config") + if [[ -n $unsafe_env_paths ]]; then + backup=$(mktemp "$mise_config.bak.XXXXXX") + cp -p -- "$mise_config" "$backup" + sed --follow-symlinks -i -E "\\%$env_section%,\\%$any_section% { \\%$unsafe_path%d; }" "$mise_config" + + printf '\n%s\n' \ + "Automatic project bin directories were removed from your Mise PATH." \ + "Your other Mise settings were preserved." + printf '\nBackup saved to:\n %s\n' "$backup" + fi + fi +fi + +if [[ -f $mise_config ]]; then + if [[ $was_ignored == "true" ]]; then + printf '\n%s\n' "This custom config remains ignored by Mise." + else + printf '\n%s\n %s\n' \ + "Mise trust for this custom config was revoked. Review it before trusting it again:" \ + "mise trust $mise_config" + fi +fi + +if [[ $remove_empty_work_dir == "true" ]]; then + rmdir "$work_dir" 2>/dev/null || true +fi diff --git a/migrations/1789294350.sh b/migrations/1789294350.sh new file mode 100644 index 000000000000..9eba04162ca4 --- /dev/null +++ b/migrations/1789294350.sh @@ -0,0 +1,11 @@ +echo "Switch TCP congestion control to BBR with fq pacing" + +# Boot applies the shipped file regardless; this only makes new connections +# use BBR now. Setting the sysctls autoloads tcp_bbr and sch_fq. Qdiscs +# already attached to interfaces stay until they are recreated, normally at +# reboot. +if [[ $(sysctl -n net.ipv4.tcp_congestion_control) == "bbr" && $(sysctl -n net.core.default_qdisc) == "fq" ]]; then + exit 0 +fi + +sudo sysctl -p /etc/sysctl.d/99-omarchy-sysctl.conf >/dev/null || omarchy-state set reboot-required diff --git a/migrations/1789444024.sh b/migrations/1789444024.sh new file mode 100644 index 000000000000..b5bc9149dded --- /dev/null +++ b/migrations/1789444024.sh @@ -0,0 +1,10 @@ +echo "Install missing headers for the Omarchy or T2 kernel" + +# Fresh ISO installs mark earlier migrations complete, so the kernel migration +# cannot repair headers omitted by those installers. Package installation is +# idempotent when another user has already applied this repair. +for kernel in linux-omarchy linux-t2; do + if omarchy-pkg-present "$kernel"; then + omarchy-pkg-add "$kernel-headers" + fi +done diff --git a/test/shell.d/chromium-claude-test.sh b/test/shell.d/chromium-claude-test.sh new file mode 100755 index 000000000000..5d8c61ef5df0 --- /dev/null +++ b/test/shell.d/chromium-claude-test.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +# Exercise the privileged installer without writing to the host's /usr/share. +if ! command -v bwrap >/dev/null || ! bwrap --ro-bind / / --unshare-user --uid 0 --gid 0 true 2>/dev/null; then + pass "user namespaces unavailable; skipping isolated Claude extension installation" + exit 0 +fi + +test_tmp=$(mktemp -d) +trap 'rm -rf "$test_tmp"' EXIT +mkdir -p "$test_tmp/share" "$test_tmp/bin" +installer="$ROOT/bin/omarchy-install-chromium-claude" +extension_id=fcoeoabgfenejglbffodgkkbkcdhcgfn +sandbox=(bwrap --ro-bind / / --bind "$test_tmp" "$test_tmp" --dev /dev --proc /proc --unshare-user) + +"${sandbox[@]}" --uid 0 --gid 0 --bind "$test_tmp/share" /usr/share bash "$installer" +for browser in chromium google-chrome microsoft-edge; do + file="$test_tmp/share/$browser/extensions/$extension_id.json" + jq -e '.external_update_url == "https://clients2.google.com/service/update2/crx"' "$file" >/dev/null || + fail "$browser registers the official Claude Web Store extension" + [[ $(stat -c '%a' "$file") == "644" ]] || fail "$browser extension registration is readable" +done +pass "Claude extension installer registers all supported browser families" + +cat >"$test_tmp/bin/pkexec" <<'SH' +#!/bin/bash +printf '%s\n' "$@" >"$AUTH_LOG" +exit 42 +SH +chmod +x "$test_tmp/bin/pkexec" +export AUTH_LOG="$test_tmp/auth-log" +export PATH="$test_tmp/bin:$PATH" + +# A read-only /usr/share and a failing auth stub prove that a repeated run +# neither rewrites the files nor requests authentication. +"${sandbox[@]}" --uid 1000 --gid 1000 --ro-bind "$test_tmp/share" /usr/share bash "$installer" "$mock_bin/omarchy-install-chromium-claude" <<'SH' +#!/bin/bash +echo claude-extension >>"$OMARCHY_TEST_CLAUDE_EXT_LOG" +if [[ ${OMARCHY_TEST_EXTENSION_FAIL:-false} == "true" ]]; then + echo "Extension installation failed" >&2 + exit 1 +fi +SH + cat >"$mock_bin/omarchy-notification-send" <<'SH' #!/bin/bash printf '%s\0' "$@" >>"$OMARCHY_TEST_NOTIFICATION_HISTORY" @@ -137,6 +147,7 @@ export OMARCHY_TEST_AGENT_MENU_LOG="$menu_log" export OMARCHY_TEST_CURSOR_INSTALL_LOG="$cursor_install_log" export OMARCHY_TEST_HERMES_INSTALL_LOG="$hermes_install_log" export OMARCHY_TEST_MUSE_LOGIN_LOG="$muse_login_log" +export OMARCHY_TEST_CLAUDE_EXT_LOG="$claude_ext_log" export OMARCHY_PATH="$ROOT" grok_package="npm:@xai-official/grok" @@ -470,6 +481,7 @@ for selection in "${!expected_agents[@]}"; do : >"$mise_log" : >"$cursor_install_log" : >"$hermes_install_log" + : >"$claude_ext_log" if [[ $expected == "cursor-agent" ]]; then OMARCHY_TEST_CURSOR_INSTALLED=true omarchy-default-agent "$selection" [[ ! -s $mise_log ]] || fail "default agent does not install Cursor through mise" @@ -494,6 +506,12 @@ for selection in "${!expected_agents[@]}"; do [[ $(omarchy-default-agent) == $expected ]] || fail "default agent canonicalizes $selection" + if [[ $expected == "claude" ]]; then + grep -qx claude-extension "$claude_ext_log" || fail "Claude selection installs the browser extension" + else + [[ ! -s $claude_ext_log ]] || fail "other agents do not install the Claude extension" + fi + mapfile -d '' -t agent_open_args <"$agent_open_log" [[ ${#agent_open_args[@]} == 1 && ${agent_open_args[0]} == "omarchy-agent" ]] || fail "default agent opens $selection after selecting it" @@ -503,6 +521,14 @@ pass "default agent selects and opens every supported provider and alias" fail "default agent stores its selection in Omarchy user config" pass "default agent stores its selection in Omarchy user config" +OMARCHY_TEST_AGENT_INSTALLED=true omarchy-default-agent pi +: >"$agent_open_log" +OMARCHY_TEST_AGENT_INSTALLED=true OMARCHY_TEST_EXTENSION_FAIL=true omarchy-default-agent claude >"$test_tmp/extension-failure" 2>&1 +[[ $(omarchy-default-agent) == "claude" ]] || fail "extension installation failure still selects Claude" +mapfile -d '' -t agent_open_args <"$agent_open_log" +[[ ${agent_open_args[*]} == "omarchy-agent" ]] || fail "extension installation failure still launches Claude" +[[ ! -s $test_tmp/extension-failure ]] || fail "extension installation failure is silent" +pass "extension installation failure silently continues selecting and launching Claude" OMARCHY_TEST_AGENT_INSTALLED=true omarchy-default-agent pi : >"$notification_history" : >"$agent_open_log" diff --git a/test/shell.d/kernel-headers-migration-test.sh b/test/shell.d/kernel-headers-migration-test.sh new file mode 100755 index 000000000000..458ea3307ecf --- /dev/null +++ b/test/shell.d/kernel-headers-migration-test.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +set -euo pipefail +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +tmp_dir=$(mktemp -d) +trap 'rm -rf "$tmp_dir"' EXIT +mkdir -p "$tmp_dir/bin" +export INSTALLED_PACKAGES="$tmp_dir/installed" CALL_LOG="$tmp_dir/calls" +export PATH="$tmp_dir/bin:$ROOT/bin:$PATH" + +# Keep the real package helpers, but contain every pacman transaction here. +cat > "$tmp_dir/bin/pacman" <<'SH' +#!/bin/bash +case "$1" in + -Q) grep -Fxq -- "$2" "$INSTALLED_PACKAGES" ;; + -S) + [[ ${FAIL_INSTALL:-0} == 0 ]] || exit 1 + shift 3 # -S --noconfirm --needed + printf '%s\n' "$@" >> "$INSTALLED_PACKAGES" + printf '%s\n' "$@" >> "$CALL_LOG" + ;; + *) exit 1 ;; +esac +SH +cat > "$tmp_dir/bin/sudo" <<'SH' +#!/bin/bash +[[ $1 == "pacman" ]] || exit 1 +"$@" +SH +chmod +x "$tmp_dir/bin/"* + +migration="$ROOT/migrations/1789444024.sh" +for kernels in linux-omarchy linux-t2 'linux-omarchy linux-t2'; do + read -ra installed <<< "$kernels" + printf '%s\n' linux linux-headers "${installed[@]}" > "$INSTALLED_PACKAGES" + : > "$CALL_LOG" + bash -euo pipefail "$migration" >/dev/null + for kernel in "${installed[@]}"; do + grep -Fxq "$kernel-headers" "$INSTALLED_PACKAGES" || fail "$kernel gets its headers" + done + : > "$CALL_LOG" + bash -euo pipefail "$migration" >/dev/null + [[ ! -s $CALL_LOG ]] || fail "header repair is idempotent" + pass "missing headers are repaired once for $kernels" +done + +printf '%s\n' linux linux-aarch64 > "$INSTALLED_PACKAGES" +: > "$CALL_LOG" +bash -euo pipefail "$migration" >/dev/null +[[ ! -s $CALL_LOG ]] || fail "header repair skips unrelated kernels" +pass "header repair skips unrelated kernels" + +echo linux-omarchy > "$INSTALLED_PACKAGES" +if FAIL_INSTALL=1 bash -euo pipefail "$migration" >/dev/null; then + fail "a failed header installation must leave the migration pending" +fi +pass "header installation failure is propagated" diff --git a/test/shell.d/mise-work-path-test.sh b/test/shell.d/mise-work-path-test.sh new file mode 100644 index 000000000000..9c50b91b2540 --- /dev/null +++ b/test/shell.d/mise-work-path-test.sh @@ -0,0 +1,270 @@ +#!/bin/bash + +set -euo pipefail +source "$(dirname "${BASH_SOURCE[0]}")/base-test.sh" + +require_command mise + +test_dir=$(mktemp -d) +trap 'rm -rf "$test_dir"' EXIT +migration="$ROOT/migrations/1789095456.sh" + +run_migration() { + local test_home="$1" + + env -i \ + HOME="$test_home" \ + XDG_CACHE_HOME="$test_home/.cache" \ + XDG_CONFIG_HOME="$test_home/.config" \ + XDG_DATA_HOME="$test_home/.local/share" \ + XDG_STATE_HOME="$test_home/.local/state" \ + MISE_PARANOID="${OMARCHY_TEST_MISE_PARANOID:-false}" \ + PATH=/usr/bin \ + bash -euo pipefail "$migration" +} + +run_mise() { + local test_home="$1" + shift + + env -i \ + HOME="$test_home" \ + XDG_CACHE_HOME="$test_home/.cache" \ + XDG_CONFIG_HOME="$test_home/.config" \ + XDG_DATA_HOME="$test_home/.local/share" \ + XDG_STATE_HOME="$test_home/.local/state" \ + MISE_PARANOID="${OMARCHY_TEST_MISE_PARANOID:-false}" \ + PATH=/usr/bin \ + mise "$@" +} + +mise_environment() { + local test_home="$1" + local project="$2" + + ( + cd "$project" + run_mise "$test_home" env -s bash + ) +} + +mise_path_active() { + local test_home="$1" + local project="$2" + local output + + if ! output=$(mise_environment "$test_home" "$project" 2>/dev/null); then + return 1 + fi + + grep -F "$project/bin" <<<"$output" >/dev/null +} + +assert_unsafe_variant_removed() { + local variant="$1" + local assignment="$2" + local variant_home="$test_dir/$variant-home" + local variant_config="$variant_home/Work/.mise.toml" + local variant_project="$variant_home/Work/tries/untrusted-repository" + + mkdir -p "$variant_project/bin" + printf '[env]\n%s\n' "$assignment" >"$variant_config" + run_mise "$variant_home" trust "$variant_config" >/dev/null + + mise_path_active "$variant_home" "$variant_project" || fail "$variant legacy config prepends the repository bin directory" + + run_migration "$variant_home" >/dev/null + if mise_path_active "$variant_home" "$variant_project"; then + fail "$variant repository bin directory remains in PATH after migration" + fi +} + +install_home="$test_dir/install-home" +install_log="$test_dir/install-mise.log" +mkdir -p "$install_home" "$test_dir/bin" +cat >"$test_dir/bin/mise" <<'SH' +#!/bin/bash +printf '%s\n' "$*" >>"$MISE_TEST_LOG" +SH +chmod +x "$test_dir/bin/mise" + +env \ + HOME="$install_home" \ + MISE_TEST_LOG="$install_log" \ + OMARCHY_SETUP_CONTEXT=runtime \ + PATH="$test_dir/bin:/usr/bin" \ + bash -euo pipefail -c 'source "$1"' bash "$ROOT/install/user/mise-work.sh" + +[[ -d $install_home/Work/tries ]] || fail "installer creates the work and tries directories" +[[ ! -e $install_home/Work/.mise.toml ]] || fail "installer does not create a trusted Work Mise config" +[[ $(<"$install_log") == "use -g node@latest" ]] || fail "installer only invokes Mise for the global Node setup" +pass "new installs do not add project bin directories to PATH" + +stock_home="$test_dir/stock-home" +stock_config="$stock_home/Work/.mise.toml" +stock_project="$stock_home/Work/tries/untrusted-repository" +mkdir -p "$stock_project/bin" +cat >"$stock_config" <<'TOML' +[env] +_.path = "{{ cwd }}/bin" +TOML +run_mise "$stock_home" trust "$stock_config" >/dev/null + +mise_path_active "$stock_home" "$stock_project" || fail "legacy config prepends the repository bin directory" + +run_migration "$stock_home" >/dev/null +[[ ! -e $stock_config ]] || fail "migration removes the stock Work Mise config" +cat >"$stock_config" <<'TOML' +[env] +_.path = "{{ cwd }}/bin" +TOML +if mise_path_active "$stock_home" "$stock_project"; then + fail "recreated Work config remains trusted after migration" +fi +run_migration "$stock_home" >/dev/null +[[ ! -e $stock_config ]] || fail "stock migration is idempotent" +pass "migration removes the repository bin directory and revokes the Work trust root" + +assert_unsafe_variant_removed inline-comment '_.path = "{{ cwd }}/bin" # Omarchy default' +assert_unsafe_variant_removed single-quoted "_.path = '{{ cwd }}/bin'" +pass "migration removes annotated and single-quoted project bin paths" + +custom_home="$test_dir/custom-home" +custom_config="$custom_home/Work/.mise.toml" +mkdir -p "$(dirname "$custom_config")" +cat >"$custom_config" <<'TOML' +[env] +KEEP = "yes" + _.path = "{{ cwd }}/bin" +# _.path = "{{ cwd }}/bin" + +[tools] +ruby = "latest" + +[other] +_.path = "{{ cwd }}/bin" +TOML +cp "$custom_config" "$test_dir/custom-original" +cat >"$test_dir/custom-expected" <<'TOML' +[env] +KEEP = "yes" +# _.path = "{{ cwd }}/bin" + +[tools] +ruby = "latest" + +[other] +_.path = "{{ cwd }}/bin" +TOML +chmod 600 "$custom_config" +run_mise "$custom_home" trust "$custom_config" >/dev/null + +custom_output=$(run_migration "$custom_home") +cmp -s "$test_dir/custom-expected" "$custom_config" || fail "migration preserves unrelated custom Mise settings" +[[ $(stat -c %a "$custom_config") == "600" ]] || fail "migration preserves custom config permissions" +grep -F "mise trust $custom_config" <<<"$custom_output" >/dev/null || fail "migration explains how to review and re-trust a custom config" +custom_backups=("$custom_config".bak.*) +[[ -f ${custom_backups[0]} ]] || fail "migration backs up a customized Mise config" +(( ${#custom_backups[@]} == 1 )) || fail "migration creates one custom config backup" +cmp -s "$test_dir/custom-original" "${custom_backups[0]}" || fail "custom config backup preserves the original" + +run_migration "$custom_home" >/dev/null +custom_backups=("$custom_config".bak.*) +(( ${#custom_backups[@]} == 1 )) || fail "custom migration does not create another backup on rerun" +cmp -s "$test_dir/custom-expected" "$custom_config" || fail "custom migration is idempotent" +pass "custom Mise settings, permissions, and original backup survive the repair" + +unrelated_home="$test_dir/unrelated-home" +unrelated_config="$unrelated_home/Work/.mise.toml" +unrelated_project="$unrelated_home/Work/tries/untrusted-repository" +mkdir -p "$unrelated_project/bin" +printf '[env]\nKEEP = "yes"\n' >"$unrelated_config" +cp "$unrelated_config" "$test_dir/unrelated-original" +run_mise "$unrelated_home" trust "$unrelated_config" >/dev/null +run_migration "$unrelated_home" >/dev/null +cmp -s "$test_dir/unrelated-original" "$unrelated_config" || fail "unrelated Mise config remains unchanged" +unrelated_backups=("$unrelated_config".bak.*) +[[ ! -e ${unrelated_backups[0]} ]] || fail "unchanged Mise config is not backed up" +printf '[env]\n_.path = "{{ cwd }}/bin"\n' >"$unrelated_config" +if mise_path_active "$unrelated_home" "$unrelated_project"; then + fail "safe Work config retains its old trust grant" +fi + +absent_home="$test_dir/absent-home" +absent_config="$absent_home/Work/.mise.toml" +absent_project="$absent_home/Work/tries/untrusted-repository" +mkdir -p "$(dirname "$absent_config")" +printf '[env]\n_.path = "{{ cwd }}/bin"\n' >"$absent_config" +run_mise "$absent_home" trust "$absent_config" >/dev/null +rm "$absent_config" +rmdir "$absent_home/Work" +run_migration "$absent_home" >/dev/null +[[ ! -e $absent_home/Work ]] || fail "migration does not retain a temporary Work directory" +mkdir -p "$absent_project/bin" +printf '[env]\n_.path = "{{ cwd }}/bin"\n' >"$absent_config" +if mise_path_active "$absent_home" "$absent_project"; then + fail "deleted Work directory retains its stale trust grant" +fi +pass "migration leaves unrelated configs alone and revokes dangling Work trust" + +paranoid_home="$test_dir/paranoid-home" +paranoid_work="$paranoid_home/Work" +paranoid_config="$paranoid_work/.mise.toml" +paranoid_project="$paranoid_work/tries/untrusted-repository" +mkdir -p "$paranoid_project/bin" +printf '[env]\n_.path = "{{ cwd }}/bin"\n' >"$paranoid_config" +OMARCHY_TEST_MISE_PARANOID=true run_mise "$paranoid_home" trust "$paranoid_config" >/dev/null +OMARCHY_TEST_MISE_PARANOID=true mise_path_active "$paranoid_home" "$paranoid_project" || fail "paranoid legacy config prepends the repository bin directory" +rm -r "$paranoid_work" + +OMARCHY_TEST_MISE_PARANOID=true run_migration "$paranoid_home" >/dev/null +[[ ! -e $paranoid_work ]] || fail "paranoid migration removes its temporary Work directory" +mkdir -p "$paranoid_project/bin" +printf '[env]\n_.path = "{{ cwd }}/bin"\n' >"$paranoid_config" +if OMARCHY_TEST_MISE_PARANOID=true mise_path_active "$paranoid_home" "$paranoid_project"; then + fail "paranoid migration retains content-bound trust for the deleted legacy config" +fi +pass "migration revokes stale content-bound trust in Mise paranoid mode" + +ignored_home="$test_dir/ignored-home" +ignored_config="$ignored_home/Work/.mise.toml" +ignored_project="$ignored_home/Work/tries/untrusted-repository" +mkdir -p "$ignored_project/bin" +cat >"$ignored_config" <<'TOML' +[env] +_.path = "{{ cwd }}/bin" +KEEP = "yes" +TOML +run_mise "$ignored_home" trust "$ignored_config" >/dev/null +run_mise "$ignored_home" trust --ignore "$ignored_config" >/dev/null + +ignored_output=$(run_migration "$ignored_home") +grep -F '{{ cwd }}/bin' "$ignored_config" >/dev/null && fail "ignored config retains the unsafe path" +grep -Fx 'KEEP = "yes"' "$ignored_config" >/dev/null || fail "ignored config keeps unrelated settings" +ignored_entries=("$ignored_home/.local/state/mise/ignored-configs/"*) +[[ -L ${ignored_entries[0]} ]] || fail "migration preserves the explicit Mise ignore marker" +(( ${#ignored_entries[@]} == 1 )) || fail "migration preserves exactly one Mise ignore marker" +ignored_target=$(readlink "${ignored_entries[0]}") +[[ $ignored_target == $ignored_home/Work || $ignored_target == $ignored_config ]] || fail "preserved Mise ignore marker still targets the Work config" +grep -F "remains ignored by Mise" <<<"$ignored_output" >/dev/null || fail "migration reports that the custom config remains ignored" +if mise_path_active "$ignored_home" "$ignored_project"; then + fail "ignored config becomes active after migration" +fi +pass "migration preserves an explicit decision to ignore the Work config" + +symlink_home="$test_dir/symlink-home" +symlink_config="$symlink_home/Work/.mise.toml" +symlink_target="$test_dir/dotfiles-mise.toml" +mkdir -p "$(dirname "$symlink_config")" +cat >"$symlink_target" <<'TOML' +[env] +_.path = "{{ cwd }}/bin" +KEEP = "yes" +TOML +ln -s "$symlink_target" "$symlink_config" + +run_migration "$symlink_home" >/dev/null +[[ -L $symlink_config ]] || fail "migration preserves a dotfile symlink" +grep -F '{{ cwd }}/bin' "$symlink_target" >/dev/null && fail "symlink target retains the unsafe path" +grep -Fx 'KEEP = "yes"' "$symlink_target" >/dev/null || fail "symlink target keeps unrelated settings" +pass "custom dotfile symlinks survive the repair" diff --git a/test/shell.d/screenrecording-test.sh b/test/shell.d/screenrecording-test.sh index 7859ec14b377..438ccc57a9b2 100644 --- a/test/shell.d/screenrecording-test.sh +++ b/test/shell.d/screenrecording-test.sh @@ -299,3 +299,114 @@ grep -F 'move = { "(monitor_w-monitor_h*2/9-40)", "(monitor_h-monitor_h/4-40)" } grep -F 'move = { "(monitor_w-monitor_h*3/10-40)", "(monitor_h-monitor_h*27/80-40)" }' "$webcam_rules" >/dev/null || \ fail "large webcam starts at its final corner position" pass "webcam size rules place the initial window in its final corner" + +# The stop path reads the recording state file back and uses its contents as a +# path -- ffmpeg writes beside it, `mv` replaces it, `rm -f` deletes its +# preview -- so it has to live in the per-user runtime directory rather than +# under a name in world-writable /tmp that another account can create first. +recording_dir="$tmp_dir/recordings" +mkdir -p "$recording_dir" + +cat >"$stub_bin/pgrep" <<'SH' +#!/bin/bash +exit 1 +SH + +cat >"$stub_bin/omarchy-hyprland-monitor-focused" <<'SH' +#!/bin/bash +printf 'DP-1\n' +SH + +cat >"$stub_bin/gpu-screen-recorder" <<'SH' +#!/bin/bash +for i in "$@"; do + [[ -n ${take_next:-} ]] && { : >"$i"; break; } + [[ $i == "-o" ]] && take_next=1 +done +sleep 5 +SH + +cat >"$stub_bin/omarchy-shell" <<'SH' +#!/bin/bash +exit 0 +SH + +chmod +x "$stub_bin"/pgrep "$stub_bin"/omarchy-hyprland-monitor-focused \ + "$stub_bin"/gpu-screen-recorder "$stub_bin"/omarchy-shell + +# Compare that name across the run rather than demanding it be absent: the +# whole point of the finding is that anyone can own it already, and a leftover +# from a pre-fix recording would red-light the fixed script. +tmp_state="/tmp/omarchy-screenrecord-filename" +tmp_state_before=$(stat -c '%y %s' "$tmp_state" 2>/dev/null || true) + +OMARCHY_SCREENRECORD_DIR="$recording_dir" \ + "$ROOT/bin/omarchy-capture-screenrecording" --fullscreen >/dev/null 2>&1 + +pkill -f "$stub_bin/gpu-screen-recorder" 2>/dev/null || true + +[[ $(stat -c '%y %s' "$tmp_state" 2>/dev/null) == "$tmp_state_before" ]] || + fail "screen recording keeps no state under a fixed /tmp name" +pass "screen recording keeps no state under a fixed /tmp name" + +[[ -s $XDG_RUNTIME_DIR/omarchy-screenrecord-filename ]] || + fail "the recording state file lives in the per-user runtime directory" \ + "$(ls -a "$XDG_RUNTIME_DIR")" +pass "the recording state file lives in the per-user runtime directory" + +[[ $(<"$XDG_RUNTIME_DIR/omarchy-screenrecord-filename") == "$recording_dir"/* ]] || + fail "the recording state file names the recording that was started" \ + "$(<"$XDG_RUNTIME_DIR/omarchy-screenrecord-filename")" +pass "the recording state file names the recording that was started" + +# The :-/tmp fallback would reopen the hole this PR closes. A recording +# started without a session runtime dir has to land under the state directory. +state_home="$tmp_dir/state-home" +mkdir -p "$state_home/omarchy" "$tmp_dir/home-fallback" +chmod 755 "$state_home/omarchy" +tmp_state_before=$(stat -c '%y %s' "$tmp_state" 2>/dev/null || true) + +env -u XDG_RUNTIME_DIR \ + HOME="$tmp_dir/home-fallback" \ + XDG_STATE_HOME="$state_home" \ + OMARCHY_SCREENRECORD_DIR="$recording_dir" \ + "$ROOT/bin/omarchy-capture-screenrecording" --fullscreen >/dev/null 2>&1 + +pkill -f "$stub_bin/gpu-screen-recorder" 2>/dev/null || true + +[[ $(stat -c '%y %s' "$tmp_state" 2>/dev/null) == "$tmp_state_before" ]] || + fail "without a runtime dir, screen recording still keeps no state under a fixed /tmp name" +pass "without a runtime dir, screen recording still keeps no state under a fixed /tmp name" + +fallback_file="$state_home/omarchy/omarchy-screenrecord-filename" +[[ -s $fallback_file ]] || + fail "without a runtime dir the recording state file lives in the state directory" \ + "$(ls -la "$state_home/omarchy" 2>/dev/null || true)" +pass "without a runtime dir the recording state file lives in the state directory" + +[[ $(<"$fallback_file") == "$recording_dir"/* ]] || + fail "the fallback state file names the recording that was started" \ + "$(<"$fallback_file")" +pass "the fallback state file names the recording that was started" + +# The overlay resizer reads the region file the recorder writes, so the two +# have to resolve the same fallback as well as the same runtime dir. +: >"$OMARCHY_TEST_HYPRCTL_ARGS" +echo "800x600+100+100" >"$state_home/omarchy/omarchy-screenrecord-region" +env -u XDG_RUNTIME_DIR \ + HOME="$tmp_dir/home-fallback" \ + XDG_STATE_HOME="$state_home" \ + "$ROOT/bin/omarchy-capture-webcam-resize" reset + +printf '%s\n' \ + 'dispatch hl.dsp.window.resize({ window = "address:0xabc", x = 133, y = 150 })' \ + 'dispatch hl.dsp.window.move({ window = "address:0xabc", x = 727, y = 510 })' >"$expected_hyprctl_args" + +if ! cmp -s "$OMARCHY_TEST_HYPRCTL_ARGS" "$expected_hyprctl_args"; then + fail "without a runtime dir the webcam anchors to the recorded region" "$(diff -u "$expected_hyprctl_args" "$OMARCHY_TEST_HYPRCTL_ARGS")" +fi +pass "without a runtime dir the webcam anchors to the recorded region" + +mode=$(stat -c '%a' "$state_home/omarchy" 2>/dev/null || stat -f '%Lp' "$state_home/omarchy") +[[ $mode == "700" ]] || fail "fallback directory is private even when it already existed" "mode: $mode" +pass "fallback directory is private even when it already existed" diff --git a/test/shell.d/unowned-system-paths-test.sh b/test/shell.d/unowned-system-paths-test.sh index e24506191470..a333e69b646f 100755 --- a/test/shell.d/unowned-system-paths-test.sh +++ b/test/shell.d/unowned-system-paths-test.sh @@ -34,6 +34,9 @@ allowed = { # they are written. Both drop configuration into another project's tree rather # than Omarchy's, which is why neither is a candidate for omarchy-settings. "/usr/share/chromium/extensions", + # Claude's extension is registered only when the user selects Claude. + "/usr/share/google-chrome/extensions", + "/usr/share/microsoft-edge/extensions", "/usr/lib/firefox/distribution", # Static content that belongs in omarchy-settings. It cannot move there in the # same release that first ships omarchy-update-system-pkgs-when-conflicted: the diff --git a/test/shell.d/update-keyring-test.sh b/test/shell.d/update-keyring-test.sh new file mode 100644 index 000000000000..15d5bb52fbec --- /dev/null +++ b/test/shell.d/update-keyring-test.sh @@ -0,0 +1,137 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +test_tmp=$(mktemp -d) +trap 'rm -rf "$test_tmp"' EXIT + +stub_bin="$test_tmp/bin" +log_file="$test_tmp/keyring.log" +mkdir -p "$stub_bin" + +# Behavior is driven by env vars so each case can pick its failure point: +# KEYRING_TEST_PKG_MISSING exit status of omarchy-pkg-missing (default 1: installed) +# KEYRING_TEST_LIST_FAIL_ON which --list-keys call fails, counted per run (default: none) +# KEYRING_TEST_RECV_STATUS exit status of --recv-keys (default 0) +# KEYRING_TEST_REINSTALL_STATUS exit status of the archlinux-keyring reinstall (default 0) +cat >"$stub_bin/sudo" <<'SH' +#!/bin/bash + +printf 'sudo' >>"$KEYRING_TEST_LOG" +for arg in "$@"; do + printf '\t%s' "$arg" >>"$KEYRING_TEST_LOG" +done +printf '\n' >>"$KEYRING_TEST_LOG" + +if [[ $1 == "pacman-key" && $2 == "--list-keys" ]]; then + calls_file="$KEYRING_TEST_DIR/list-calls" + calls=$(( $(cat "$calls_file" 2>/dev/null || echo 0) + 1 )) + echo "$calls" >"$calls_file" + if [[ ${KEYRING_TEST_LIST_FAIL_ON:-} == "$calls" ]]; then + exit 1 + fi + exit 0 +fi + +if [[ $1 == "pacman-key" && $2 == "--recv-keys" ]]; then + exit "${KEYRING_TEST_RECV_STATUS:-0}" +fi + +if [[ $1 == "pacman-key" && $2 == "--lsign-key" ]]; then + exit 0 +fi + +if [[ $1 == "pacman" && $* == *archlinux-keyring* ]]; then + exit "${KEYRING_TEST_REINSTALL_STATUS:-0}" +fi + +exit 0 +SH +chmod +x "$stub_bin/sudo" + +cat >"$stub_bin/omarchy-pkg-missing" <<'SH' +#!/bin/bash + +exit "${KEYRING_TEST_PKG_MISSING:-1}" +SH +chmod +x "$stub_bin/omarchy-pkg-missing" + +cat >"$stub_bin/omarchy-pkg-add" <<'SH' +#!/bin/bash + +printf 'pkg-add\t%s\n' "$1" >>"$KEYRING_TEST_LOG" +exit 0 +SH +chmod +x "$stub_bin/omarchy-pkg-add" + +run_keyring() { + KEYRING_TEST_LOG="$log_file" \ + KEYRING_TEST_DIR="$test_tmp" \ + PATH="$stub_bin:$PATH" \ + "$ROOT/bin/omarchy-update-keyring" "$@" +} + +# Everything healthy: the key and package are present, the reinstall works. +: >"$log_file" +rm -f "$test_tmp/list-calls" +run_keyring >"$test_tmp/ok.out" + +grep -F "Keys are correct" "$test_tmp/ok.out" >/dev/null || + fail "update-keyring reports success when the keyring is healthy" "$(cat "$test_tmp/ok.out")" +pass "update-keyring reports success when the keyring is healthy" + +grep -Eq $'^sudo\tpacman\t-Sy\t--noconfirm\tarchlinux-keyring$' "$log_file" || + fail "update-keyring still reinstalls archlinux-keyring" "$(cat "$log_file")" +pass "update-keyring still reinstalls archlinux-keyring" + +# Key and package missing: the full populate path runs and verifies at the end. +: >"$log_file" +rm -f "$test_tmp/list-calls" +KEYRING_TEST_PKG_MISSING=0 run_keyring >"$test_tmp/populate.out" + +grep -F "Keys are correct" "$test_tmp/populate.out" >/dev/null || + fail "update-keyring populates a missing keyring and reports success" "$(cat "$test_tmp/populate.out")" +for expected in 'recv-keys' 'lsign-key' $'pkg-add\tomarchy-keyring'; do + grep -Eq "$expected" "$log_file" || + fail "update-keyring populates a missing keyring and reports success" "$(cat "$log_file")" +done +pass "update-keyring populates a missing keyring and reports success" + +# recv-keys failing must stop the script, not end in "Keys are correct". +: >"$log_file" +rm -f "$test_tmp/list-calls" +if KEYRING_TEST_PKG_MISSING=0 KEYRING_TEST_RECV_STATUS=1 run_keyring >"$test_tmp/recv.out" 2>&1; then + fail "update-keyring fails when recv-keys fails" +fi +if grep -F "Keys are correct" "$test_tmp/recv.out" >/dev/null; then + fail "update-keyring fails when recv-keys fails" "$(cat "$test_tmp/recv.out")" +fi +if grep -q 'lsign-key' "$log_file"; then + fail "update-keyring stops at the failed recv instead of signing anyway" "$(cat "$log_file")" +fi +pass "update-keyring fails when recv-keys fails" + +# A failed archlinux-keyring reinstall must not end in success either. +: >"$log_file" +rm -f "$test_tmp/list-calls" +if KEYRING_TEST_REINSTALL_STATUS=1 run_keyring >"$test_tmp/reinstall.out" 2>&1; then + fail "update-keyring fails when the archlinux-keyring reinstall fails" +fi +if grep -F "Keys are correct" "$test_tmp/reinstall.out" >/dev/null; then + fail "update-keyring fails when the archlinux-keyring reinstall fails" "$(cat "$test_tmp/reinstall.out")" +fi +pass "update-keyring fails when the archlinux-keyring reinstall fails" + +# The closing check is what backs the success line: the first --list-keys +# passes (key present, populate skipped), the verifying one fails. +: >"$log_file" +rm -f "$test_tmp/list-calls" +if KEYRING_TEST_LIST_FAIL_ON=2 run_keyring >"$test_tmp/verify.out" 2>&1; then + fail "update-keyring fails when the final key check fails" +fi +if grep -F "Keys are correct" "$test_tmp/verify.out" >/dev/null; then + fail "update-keyring fails when the final key check fails" "$(cat "$test_tmp/verify.out")" +fi +pass "update-keyring fails when the final key check fails"