Skip to content

Instantly share code, notes, and snippets.

@laserson
Created March 7, 2024 02:28
Show Gist options
  • Save laserson/4c73c104ed04cf015e26dc00bf53f11d to your computer and use it in GitHub Desktop.
Save laserson/4c73c104ed04cf015e26dc00bf53f11d to your computer and use it in GitHub Desktop.
fish script to toggle MacOS `caffeinate`
#! /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