Refactored caffeinate machine function to process grep.
Leverages `pgrep` instead of `ps` for more efficient code.
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user