Files
arthur-os/bin/omarchy-dev-unlink
T
Ryan Hughes 6e0079a66d omarchy-dev-link/unlink: strip prior dev-link bin/ from PATH
Sequential 'dev-link A' then 'dev-link B' previously left A/bin in
PATH because the prepend didn't strip the old one. unlink had the
same issue (it was trying to strip $(dirname $0), which only worked
if you invoked unlink via an absolute path that happened to match
the dev-link bin).

Both now read the previous OMARCHY_PATH from /etc/omarchy.conf before
overwriting/deleting it, and strip that path's bin/ from PATH before
prepending the new one (or nothing, for unlink).
2026-06-04 18:34:35 -04:00

60 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# omarchy:summary=Restore Omarchy to the package install (undo omarchy-dev-link)
# omarchy:group=dev
set -euo pipefail
if [[ $EUID -eq 0 ]]; then
echo "Error: run omarchy-dev-unlink as your user, not under sudo." >&2
exit 1
fi
if [[ ${1:-} == "-h" || ${1:-} == "--help" ]]; then
cat <<USAGE
Usage: omarchy dev unlink
Removes /etc/omarchy.conf so OMARCHY_PATH falls back to /usr/share/omarchy
(the package install). Updates Hyprland/systemd session env and restarts
omarchy-shell so live state matches.
USAGE
exit 0
fi
if [[ ! -f /etc/omarchy.conf ]]; then
echo "Not currently linked. OMARCHY_PATH already resolves to /usr/share/omarchy."
exit 0
fi
# Capture the path dev-link wrote BEFORE we delete the conf, so we know
# which bin/ to strip from PATH.
prior_target=$(sed -n 's/^[[:space:]]*export[[:space:]]\+OMARCHY_PATH="\?\([^"]*\)"\?/\1/p' /etc/omarchy.conf | tail -1)
sudo rm -f /etc/omarchy.conf
echo "Removed /etc/omarchy.conf"
export OMARCHY_PATH=/usr/share/omarchy
if [[ -n $prior_target ]]; then
PATH=$(printf '%s' "$PATH" | tr ':' '\n' | grep -vFx "$prior_target/bin" | paste -sd:)
export PATH
fi
if command -v hyprctl >/dev/null 2>&1 && hyprctl version &>/dev/null; then
hyprctl setenv OMARCHY_PATH /usr/share/omarchy >/dev/null
hyprctl setenv PATH "$PATH" >/dev/null
echo " Updated Hyprland session env."
systemctl --user import-environment OMARCHY_PATH PATH 2>/dev/null || true
echo " Updated systemd --user env."
if pgrep -x quickshell >/dev/null 2>&1; then
omarchy-restart-shell
echo " Restarted omarchy-shell."
fi
hyprctl reload >/dev/null
echo " Reloaded Hyprland config."
fi
echo
echo "Done. Existing shells still have the old OMARCHY_PATH until restarted."