From 38da7492badf60fc5e42ffcee6f15ee775e39615 Mon Sep 17 00:00:00 2001 From: alterNERDtive Date: Mon, 12 Feb 2024 12:19:58 +0100 Subject: [PATCH] feat: sway support for -a --- hyprfreeze | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hyprfreeze b/hyprfreeze index 7d05a3e..f9febfe 100755 --- a/hyprfreeze +++ b/hyprfreeze @@ -56,7 +56,14 @@ function toggleFreeze() { function getPidByActive() { debugPrint "Getting PID by active window..." - PID=$(hyprctl activewindow -j | jq '.pid') + if [[ "hyprland" == "$DESKTOP" ]]; then + PID=$(hyprctl activewindow -j | jq '.pid') + elif [[ "sway" == "$DESKTOP" ]]; then + PID=$(swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | .pid') + else + echo "Detecting the active window is currently not supported on $DESKTOP." + exit 1 + fi debugPrint "PID by active window: $PID" # Die if PID is not numeric (e.g. "null" if there is no active window)