Welcome to another edition of #JustWorks, a series of blog posts on all of the customizations you need to make to MacOS to get around Apple's one-size-fits-all mentality.
If you've ever fired off a long-running program in terminal and locked your screen to go get a coffee with the hopes that the job would be done when you're back an hour later, you may have noticed that things take longer to run when your screen is locked or terminal is in the background.
MacOS did this for you! It did it to save power! And for whatever reason, it doesn't seem to care that you're plugged into the mains.
Here's how to disable something called AppNap for terminal. You're going to need to open a Terminal and paste this bit:
defaults write com.apple.Terminal NSAppSleepDisabled -bool YES
Then close all of your Terminals and restart it. You can verify the state of AppNap for Terminal on the Energy panel of Activity Monitor.
I'm not a fan of the hot corner method of locking screen so here are 2 other ways to achieve screen lockage on MacOS / OSX:
Keychain Access: Toolbar Icon So You Can Click To Lock Screen
- CMD-space: Launch "Keychain Access"
- -> Preferences
- CHECK: "Show keychain status in menu bar"
Then you can lock screen by clicking the padlock on the Menu Bar and selecting "Lock Screen":
Automator and Keyboard Shortcut
Automator Service: Lock Screen via Applescript
First we have to bind an applescript to a service that starts the screensaver:
- CMD-space: Launch "Automator"
- Change "Service recieves" dropdown to "no input"
- use search bar to search for "run applescript"
- Doubleclick "Run Applescript" to add it to the service.
- Copy/Paste this code into the Applescript box replacing any existing text:
- Save as: "Lock Screen"
Next we bind a key to the new service.
- CMD-space: Launch "keyboard" (or System Preferences -> Keyboard)
- Shortcuts (top bar) -> Services (left pane) -> Lock Screen (right pane - scroll to find it)
- Add Shortcut (I added CTRL-CMD-K in this example)
OSX tip: Create a folder on your desktop called “Screenshots”, then use this method to change the default screen shot folder to the one you just added.
defaults write com.apple.screencapture location $HOME/Desktop/Screenshots; killall SystemUIServer
For anyone struggling with the way the HOME and END keys on your windows keyboard works on OSX. This will help a lot.
Add these contents to
~/Library/KeyBindings/DefaultKeyBinding.dict and restart your program.