Useless Code
I work a lot in the terminal. The simplicity and straight UI of simple text is just hard to beat. The Unix way is just awesome.
Long story short, a while back I needed a way to lock the screen of my Mac from the terminal, so I wrote one. This is quick and dirty piece of code that is just useless, but very useful. These will work with Mac OS Big Sur.
Bash Script
#!/bin/bash
open -a /System/Library/CoreServices/ScreenSaverEngine.app
Apple Script
tell application "/System/Library/CoreServices/ScreenSaverEngine.app"
activate
end tell
For Mac OS versions before Big Sur check the code below.
tell application "/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app"
activate
end tell