Files
omarchy/bin/omarchy-restart-walker
2025-12-15 18:47:13 -05:00

29 lines
937 B
Bash
Executable File

#!/bin/bash
# Detect if we're running as root (from pacman hook)
if [[ $EUID -eq 0 ]]; then
# Get the owner of this script to determine which user to run as
SCRIPT_OWNER=$(stat -c '%U' "$0")
USER_UID=$(id -u "$SCRIPT_OWNER")
# Restart services as the script owner
systemd-run --uid="$SCRIPT_OWNER" --setenv=XDG_RUNTIME_DIR="/run/user/$USER_UID" \
bash -c "
if systemctl --user is-enabled elephant.service &>/dev/null; then
systemctl --user restart elephant.service
fi
if systemctl --user is-enabled app-walker@autostart.service &>/dev/null; then
systemctl --user restart app-walker@autostart.service
fi
"
else
if systemctl --user is-enabled elephant.service &>/dev/null; then
systemctl --user restart elephant.service
fi
if systemctl --user is-enabled app-walker@autostart.service &>/dev/null; then
systemctl --user restart app-walker@autostart.service
fi
fi