aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/Tak0-Per-Window-Switch.sh
diff options
context:
space:
mode:
authorMartin Guzman <55927935+brockar@users.noreply.github.com>2026-01-21 16:18:43 -0300
committerGitHub <noreply@github.com>2026-01-21 16:18:43 -0300
commitc6198c1bedeffd08ec3f60f7ba3a41e6c5870885 (patch)
tree458c030873b4e70ff9eda0baed5df257434871f4 /config/hypr/scripts/Tak0-Per-Window-Switch.sh
parent7dedbe3d4a4560ac15987fdf8164dbbb1f4701bf (diff)
parent88a09344e8cc7cffe69a017eb752e8c6fa17ddcb (diff)
Merge pull request #927 from JaKooLit/development
Merge Development to main branch for release
Diffstat (limited to 'config/hypr/scripts/Tak0-Per-Window-Switch.sh')
-rwxr-xr-xconfig/hypr/scripts/Tak0-Per-Window-Switch.sh20
1 files changed, 16 insertions, 4 deletions
diff --git a/config/hypr/scripts/Tak0-Per-Window-Switch.sh b/config/hypr/scripts/Tak0-Per-Window-Switch.sh
index 7879fb85..7cec89a6 100755
--- a/config/hypr/scripts/Tak0-Per-Window-Switch.sh
+++ b/config/hypr/scripts/Tak0-Per-Window-Switch.sh
@@ -17,6 +17,7 @@ MAP_FILE="$HOME/.cache/kb_layout_per_window"
CFG_FILE="$HOME/.config/hypr/configs/SystemSettings.conf"
ICON="$HOME/.config/swaync/images/ja.png"
SCRIPT_NAME="$(basename "$0")"
+LISTENER_PIDFILE="$HOME/.cache/kb_layout_per_window.listener.pid"
# Ensure map file exists
touch "$MAP_FILE"
@@ -99,7 +100,7 @@ subscribe() {
local SOCKET2="$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock"
[[ -S "$SOCKET2" ]] || {
echo "Error: Hyprland socket not found." >&2
- exit 1
+ return 1
}
socat -u UNIX-CONNECT:"$SOCKET2" - | while read -r line; do
@@ -108,9 +109,20 @@ subscribe() {
}
# Ensure only one listener
-if ! pgrep -f "$SCRIPT_NAME.*--listener" >/dev/null; then
- subscribe --listener &
-fi
+start_listener_once() {
+ if [[ -f "$LISTENER_PIDFILE" ]]; then
+ local existing_pid
+ existing_pid=$(cat "$LISTENER_PIDFILE" 2>/dev/null || true)
+ if [[ -n "$existing_pid" ]] && kill -0 "$existing_pid" 2>/dev/null; then
+ return
+ fi
+ fi
+
+ subscribe &
+ echo $! >"$LISTENER_PIDFILE"
+}
+
+start_listener_once
# CLI
case "$1" in
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage