Refactored caffeinate machine function to process grep.

Leverages `pgrep` instead of `ps` for more efficient code.
This commit is contained in:
Brooke Kuhlmann
2019-12-07 14:38:52 -07:00
parent 98c4663f43
commit 39cbeefef8

View File

@@ -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"