From aacc40c954a1f2ef2fc865aabacdf279d6f48102 Mon Sep 17 00:00:00 2001 From: Ryan Hughes Date: Mon, 15 Dec 2025 19:58:59 -0500 Subject: [PATCH] Alert user if unable to restart --- bin/omarchy-restart-walker | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/bin/omarchy-restart-walker b/bin/omarchy-restart-walker index b38b08ae..2efb9d53 100755 --- a/bin/omarchy-restart-walker +++ b/bin/omarchy-restart-walker @@ -1,28 +1,22 @@ #!/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 +restart_services() { 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 + else + echo -e "\e[31mUnable to restart Walker -- RESTART MANUALLY\e[0m" 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