From 39cbeefef8faf70850d2f47caa087fe0911449d5 Mon Sep 17 00:00:00 2001 From: Brooke Kuhlmann Date: Sat, 7 Dec 2019 14:38:52 -0700 Subject: [PATCH] Refactored caffeinate machine function to process grep. Leverages `pgrep` instead of `ps` for more efficient code. --- lib/utilities.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utilities.sh b/lib/utilities.sh index 171e48c..1862935 100644 --- a/lib/utilities.sh +++ b/lib/utilities.sh @@ -19,7 +19,7 @@ export -f clean_work_path # Caffeinate machine. caffeinate_machine() { - local pid=$(ps aux | grep caffeinate | grep -v grep | awk '{print $2}') + local pid=$(pgrep -x caffeinate) if [[ -n "$pid" ]]; then printf "Whoa, tweaker, machine is already caffeinated!\n"