Skip to content

Instantly share code, notes, and snippets.

@neilio
Created July 23, 2025 13:29
Show Gist options
  • Save neilio/e2562bc2829047208afa8fdc9b348e1c to your computer and use it in GitHub Desktop.
Save neilio/e2562bc2829047208afa8fdc9b348e1c to your computer and use it in GitHub Desktop.
Raycast AppleScript that quits personal apps and sets up work environment
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Switch to Work - CPC
# @raycast.mode silent
# Documentation:
# @raycast.author Neil
# @raycast.authorURL https://neillee.com/
(* List of apps to launch *)
set theAppList to {{name:"Microsoft Teams", vis:true}, {name:"Twos", vis:true}, {name:"Microsoft Outlook", vis:true}, {name:"OneDrive", vis:false}, {name:"Arc", vis:true}, {name:"MeetingBar", vis:true}, {name:"Spark Desktop (Beta)", vis:false}}
(* List of apps to quit *)
set quitList to {{name:"Safari"}, {name:"Safari Technology Preview"}, {name:"Google Chrome Canary"}, {name:"Microsoft Edge Canary"}, {name:"Discord"}, {name:"Beeper Desktop"}, {name:"Messages"}, {name:"Voicenotes"}}
(* Launch the apps *)
repeat with currentApp in theAppList
tell application (name of currentApp) to launch
tell application "System Events"
try
if background only of process (name of currentApp) is false then
set visible of process (name of currentApp) to (vis of currentApp)
end if
end try
end tell
end repeat
(* Quit the apps *)
repeat with currentApp in quitList
set thisApp to (name of currentApp)
is_running(thisApp)
end repeat
on is_running(appname)
if application appname is running then
tell application id (id of application appname) to quit
end if
end is_running
(* Switch default email client to Spark - requires swds, included with SwiftDefaultApps
https://github.com/Lord-Kamina/SwiftDefaultApps *)
do shell script "~/bin/swda setHandler --app \"Spark Desktop (Beta)\" --mail"
(* Get display size and run Moom - https://manytricks.com/moom/ *)
tell application "Image Events"
launch
set countDisplays to count displays
quit
end tell
(* Get dimensions of desktop to figure out screen size *)
tell application "Finder"
set screen_total to bounds of window of desktop
set screen_width to item 3 of screen_total
end tell
(* Choose existing Moom layout based on screen size *)
if countDisplays > 1 or screen_width = 2560 then
tell application "Moom" to arrange windows according to snapshot "Desk"
else if screen_width = 1512 then
tell application "Moom" to arrange windows according to snapshot "1512"
else if screen_width = 1800 then
tell application "Moom" to arrange windows according to snapshot "8"
else if screen_width = 1712 then
tell application "Moom" to arrange windows according to snapshot "1712"
end if
(* Hacky way to get Arc to switch workspaces
tell application "System Events"
keystroke "3" using control down
keystroke "1" using command down
end tell
*)
(* Tell Fantastical to switch calendar set
-- open location "x-fantastical3://show/set?name=Work"
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment