diff options
Diffstat (limited to 'config/hypr/scripts/LuaAutoReload.sh')
| -rwxr-xr-x | config/hypr/scripts/LuaAutoReload.sh | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/config/hypr/scripts/LuaAutoReload.sh b/config/hypr/scripts/LuaAutoReload.sh index 4a9d5040..128c1fc9 100755 --- a/config/hypr/scripts/LuaAutoReload.sh +++ b/config/hypr/scripts/LuaAutoReload.sh @@ -9,8 +9,23 @@ set -euo pipefail -watch_root="$HOME/.config/hypr" +watch_root="${XDG_CONFIG_HOME:-$HOME/.config}/hypr" [ -d "$watch_root" ] || exit 0 +session="${HYPRLAND_INSTANCE_SIGNATURE:-default}" +pid_file="/tmp/hypr-lua-autoreload-${session}.pid" + +if [ -f "$pid_file" ]; then + existing_pid="$(cat "$pid_file" 2>/dev/null || true)" + if [ -n "$existing_pid" ] && kill -0 "$existing_pid" 2>/dev/null; then + exit 0 + fi +fi + +echo "$$" >"$pid_file" +cleanup() { + rm -f "$pid_file" +} +trap cleanup EXIT INT TERM reload_hypr() { hyprctl reload >/dev/null 2>&1 || true |
