Getting Caffeinated on MacOS

I use my Macbook like a desktop. It's always plugged into my dual monitors, with my keyboard, mic, and other accessories I use every day. So I don't like trying to wake it up because sometimes it decides I need to enter a password in order to use my accessories (like my keyboard). This means I have to slide it out from its nook, open it up, and type my password in on the laptop itself. (For reasons I don't fully understand it usually happens that I can't use my TouchID on it in this scenario!)

So to fix this, I just keep my laptop from going to sleep.

I do this with a builtin MacOS command called caffeinate. This command by default, lives in /usr/bin/caffeinate and can be called from the Terminal quite simply. However, it runs in the foreground meaning you either need to open a new tab, or bury it manually.

To get around it, I use these modified settings:

caffeinate -disu &

Which does:

And then the & is a bash-ism that runs that process in the background by default. You can run ps auwwx | grep caffeinate to see that process running in the background. You could also grab the pid and kill it if you wanted to.