Created
March 7, 2024 02:28
-
-
Save laserson/4c73c104ed04cf015e26dc00bf53f11d to your computer and use it in GitHub Desktop.
fish script to toggle MacOS `caffeinate`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env fish | |
set target_pids (pgrep caffeinate) | |
set num_pids (count $target_pids) | |
if test $num_pids -eq 0 | |
caffeinate -d -t 43200 | |
else | |
for target_pid in $target_pids | |
kill $target_pid | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment