I’ve set my Mac to display screensavers after 5 minutes of inactivity. We know there’s a ‘caffeinate‘ command to prevent my Mac from going to sleep.
In this case, sometimes we just want to be away from my Mac to make coffee, make a phone call, or whatever, and it’s only for a short time.
I use Caffeinate to prevent my Mac from displaying screensavers when needed. The command I use is ‘caffeinate -t 1800’. What does this command mean? -t means time in seconds, the command keeps your Mac awake for the specified duration, 1800 is equal of thirty minutes (1800 seconds/60 seconds=30).

However, I noticed that when I returned, my Mac was displaying the screensaver even though the caffeinate command above was still running in the Mac OS Terminal. Very strange.
Then I changed the command above to ‘caffeinate -d’. This command is caffeinate -d: prevents the display from sleeping. Voila, it worked.

So, use this command if you only want to prevent screensavers from appearing when you’ve only been away for a few minutes and the Mac is doing something you don’t want the screensavers to disturb.
To turn off the above command, press Control + C in the active terminal window below the caffeinate command above.
Note: I’m using Mac OS Sequoia when writing this blog.