From a0174adaccb16db2ad1f88f91d50459c95b4c29d Mon Sep 17 00:00:00 2001 From: alterNERDtive Date: Mon, 12 Feb 2024 12:41:05 +0100 Subject: [PATCH] fix: check for numeric PID in toggleFreeze --- hyprfreeze | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hyprfreeze b/hyprfreeze index 39e3d10..3858dc9 100644 --- a/hyprfreeze +++ b/hyprfreeze @@ -58,6 +58,12 @@ function getPidByActive() { debugPrint "Getting PID by active window..." PID=$(hyprctl activewindow -j | jq '.pid') debugPrint "PID by active window: $PID" + + # Die if PID is not numeric (e.g. "null" if there is no active window) + if ! [[ $PID == ?(-)+([[:digit:]]) ]]; then + echo "Cannot freeze window with invalid PID $PID." + exit 1 + fi } function getPidByPid() {