When the script is run under outer sudo, the environment loses HYPRLAND_INSTANCE_SIGNATURE, XDG_RUNTIME_DIR, and DBUS_SESSION_BUS_ADDRESS, so the 'hyprctl version' check silently fails and the live-session refresh (setenv / import-environment / restart shell / hyprctl reload) gets skipped. The user is left with /etc/omarchy.conf written but no session updates — confusing because the env in the current shell still shows the old value. Reject EUID=0 invocations with a clear message pointing at the right pattern: invoke as your user, the script prompts for sudo only when it needs to write /etc/omarchy.conf.
59 lines
1.7 KiB
Bash
Executable File
59 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. The script" >&2
|
|
echo " will prompt for sudo when it needs to remove /etc/omarchy.conf." >&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
|
|
|
|
sudo rm -f /etc/omarchy.conf
|
|
echo "Removed /etc/omarchy.conf"
|
|
|
|
# Update the current shell.
|
|
export OMARCHY_PATH=/usr/share/omarchy
|
|
# Drop the prepended checkout bin/ from PATH if present.
|
|
PATH=$(printf '%s' "$PATH" | tr ':' '\n' | grep -vFx "$(dirname "$0")" | paste -sd:)
|
|
export PATH
|
|
|
|
# Update the live Hyprland session.
|
|
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."
|