fix: freezing two windows with the same pid

This commit is contained in:
2025-07-12 03:58:44 +03:00
parent 119ab8fa2b
commit 0d216d3d9d

View File

@@ -15,30 +15,8 @@ function handle {
# Get all window information once # Get all window information once
window_info=$(hyprctl clients) window_info=$(hyprctl clients)
# Process last focused window (unfocused)
if [[ -n "$last_focused_window" ]]; then
# Extract tags
tags=$(echo "$window_info" | awk -v addr="$last_focused_window" '
$0 ~ "Window " addr {found=1}
found && /tags:/ {print $0; found=0; exit}
' | sed 's/.*tags: //;s/)//')
# Extract PID
pid=$(echo "$window_info" | awk -v addr="$last_focused_window" '
$0 ~ "Window " addr {found=1}
found && /pid:/ {print $2; found=0; exit}
')
# Process if window has zawarudo tag
if [[ -n "$tags" && -n "$pid" ]]; then
if [[ "$tags" == *"zawarudo"* ]]; then
echo freeze $current_pid
kill -STOP $pid 2>/dev/null
fi
fi
fi
# Process current focused window # Process current focused window
current_pid=""
if [[ -n "$current_window" ]]; then if [[ -n "$current_window" ]]; then
# Extract tags # Extract tags
current_tags=$(echo "$window_info" | awk -v addr="$current_window" ' current_tags=$(echo "$window_info" | awk -v addr="$current_window" '
@@ -60,6 +38,29 @@ function handle {
fi fi
fi fi
fi fi
# Process last focused window (unfocused)
if [[ -n "$last_focused_window" ]]; then
# Extract tags
tags=$(echo "$window_info" | awk -v addr="$last_focused_window" '
$0 ~ "Window " addr {found=1}
found && /tags:/ {print $0; found=0; exit}
' | sed 's/.*tags: //;s/)//')
# Extract PID
pid=$(echo "$window_info" | awk -v addr="$last_focused_window" '
$0 ~ "Window " addr {found=1}
found && /pid:/ {print $2; found=0; exit}
')
# Process if window has zawarudo tag
if [[ -n "$tags" && -n "$pid" && "$pid" != "$current_pid" ]]; then
if [[ "$tags" == *"zawarudo"* ]]; then
echo freeze $current_pid
kill -STOP $pid 2>/dev/null
fi
fi
fi
fi fi
} }