From 37583c7afab649e205cba6e2711ddf1b1d082cff Mon Sep 17 00:00:00 2001 From: Alain Lehmann Date: Sun, 1 Dec 2024 00:19:35 +0100 Subject: [PATCH] use pgrep for stopping utm --- flake.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 85ce3ef..3e58b1f 100644 --- a/flake.nix +++ b/flake.nix @@ -77,12 +77,13 @@ self'.packages.utm pkgs.coreutils pkgs.gnused - pkgs.ps + pkgs.procps ]; text = '' # shellcheck disable=SC2009 - if ps aux | grep '/[U]TM'; then - UTM_PID=$(ps ax -o pid,command | grep '/[U]TM'| sed -ne 's/^[ ]*\([[:digit:]]*\) .*/\1/p') + if pgrep '[U]TM'; then + echo "exists" + UTM_PID=$(pgrep '[U]TM') read -r -e -p "Running at $UTM_PID. Kill? (y/N)" -i "n" answer case "$answer" in y | Y | yes ) kill "$UTM_PID" ;;