Philip Young
AppleScript is a scripting language made by Apple. It gives you superpower and helps you automate part of your workflow.
If you can't code, this quick tutorial will help you understand how easy it is to get started.
Otherwise, you probably only need to turn on and off Do Not Disturb
when you start a session & stop working. If that's the case, you can learn it from Integrate automatic Do Not Disturb with Session on Mac.
Script Editor
app. You can do it by:Finder
> Applications
> Utilities
> Script Editor
, orCMD + Space
on your Keyboard and type "Script Editor"
Script Editor
, type:1display dialog "I'm shown!"
applescript
Press the play
icon
A dialog will be shown
Congratulations. You've just wrote your first code!
Opening and closing app is very easy. Let's use Slack
as an example.
1tell application "Slack" to activate
applescript
1tell application "Slack" to quit
applescript
Slack is a good example of app to be closed with Session automation. You can force close it when you start your focus with start_session
, and reopen it again on stop_working
.
TBD
The best thing with AppleScript is you can combine all of them into single file.
Say on session_start
you want to:
Slack
Mail
Do Not Disturb
dialog
that your Session has startedThis is the AppleScript code
1tell application "Slack" to quit 2 3tell application "Mail" to quit 4 5set output to (do shell script "defaults read com.apple.controlcenter 'NSStatusItem Visible DoNotDisturb'") 6if output is "0" then 7 tell application "System Events" to keystroke "D" using {command down, shift down, option down, control down} 8 do shell script "defaults write com.apple.controlcenter 'NSStatusItem Visible DoNotDisturb' 1" 9end if 10 11display dialog "Session Started!"
applescript
Do Not Disturb section is extremely complex. Don't be discouraged. You can learn to set it up from here.
You have wrote your code. Now what?
Integrate it with Session automation! You can put your code inside Session's AppleScript folder. Look into Setup your AppleScript with Session to learn what's possible.
Sadly AppleScript is not available on iOS. but it's sibling—Apple shortcut—exists. And Session also support Apple shortcut hook 😎! In the future, it's possible to block iOS apps if, say, your 3 hour focus daily is not reached yet.
Tutorial coming soon 😊.
The possibilities are endless. If you can't code, now you can.
If you want to start Spotify, try to Google "How to play Spotify album with AppleScript". Internet will tell you how. Otherwise, keep looking into Session's website from time to time. We'll write a new tutorial on productivity, time management, automation for you.
That's it for now. Be more mindful, and keep stay focused!