mirror of
https://github.com/basecamp/omarchy.git
synced 2026-02-17 15:25:37 +00:00
Alert user if unable to restart
This commit is contained in:
@@ -1,28 +1,22 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Detect if we're running as root (from pacman hook)
|
restart_services() {
|
||||||
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
|
if systemctl --user is-enabled elephant.service &>/dev/null; then
|
||||||
systemctl --user restart elephant.service
|
systemctl --user restart elephant.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if systemctl --user is-enabled app-walker@autostart.service &>/dev/null; then
|
if systemctl --user is-enabled app-walker@autostart.service &>/dev/null; then
|
||||||
systemctl --user restart app-walker@autostart.service
|
systemctl --user restart app-walker@autostart.service
|
||||||
|
else
|
||||||
|
echo -e "\e[31mUnable to restart Walker -- RESTART MANUALLY\e[0m"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $EUID -eq 0 ]]; then
|
||||||
|
SCRIPT_OWNER=$(stat -c '%U' "$0")
|
||||||
|
USER_UID=$(id -u "$SCRIPT_OWNER")
|
||||||
|
systemd-run --uid="$SCRIPT_OWNER" --setenv=XDG_RUNTIME_DIR="/run/user/$USER_UID" \
|
||||||
|
bash -c "$(declare -f restart_services); restart_services"
|
||||||
|
else
|
||||||
|
restart_services
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user