Refuse omarchy-dev-{link,unlink} when invoked under sudo

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.
This commit is contained in:
Ryan Hughes
2026-06-04 18:34:35 -04:00
parent a2feffa803
commit f4e68d5bb2
2 changed files with 14 additions and 0 deletions
+8
View File
@@ -7,6 +7,14 @@
set -euo pipefail
if [[ $EUID -eq 0 ]]; then
echo "Error: run omarchy-dev-link as your user, not under sudo. The script" >&2
echo " will prompt for sudo when it needs to write /etc/omarchy.conf." >&2
echo " (Invoking under sudo wipes HYPRLAND_INSTANCE_SIGNATURE so the" >&2
echo " live-session refresh can't reach hyprctl.)" >&2
exit 1
fi
if [[ $# -ne 1 || $1 == "-h" || $1 == "--help" ]]; then
cat <<USAGE
Usage: omarchy dev link <path-to-checkout>
+6
View File
@@ -5,6 +5,12 @@
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