Skip to content

Instantly share code, notes, and snippets.

@stevensacks
Created January 16, 2018 12:12
Show Gist options
  • Save stevensacks/09161b828e7b1668248baa002b39af77 to your computer and use it in GitHub Desktop.
Save stevensacks/09161b828e7b1668248baa002b39af77 to your computer and use it in GitHub Desktop.
Automate launching my work environment
say "Oh k, let's work" using "Oliver"
-- go to space 3
tell application "System Events"
key code 20 using {control down}
end tell
-- start iTunes downtempo radio
tell application "Safari"
activate
delay 1
open location "https://itunes.apple.com/us/station/downtempo/ra.1057801002"
delay 2
do JavaScript "document.getElementsByClassName('action listen-in-itunes')['0'].click();" in document 1
say "First, some background music." using "Oliver"
activate
delay 1
quit
end tell
delay 1
-- go to space 1
tell application "System Events"
key code 18 using {control down}
end tell
-- launch Slack and resize it to the left half
tell application "Slack"
activate
say "Next, your chat applications" using "Oliver"
delay 6
end tell
tell application "System Events"
key code 123 using {option down, control down, command down}
end tell
-- launch Caprine and resize it to the top right
tell application "Caprine"
activate
delay 4
end tell
tell application "System Events"
key code 126 using {option down, control down, shift down}
delay 1
end tell
-- go to space 2
tell application "System Events"
key code 19 using {control down}
end tell
-- launch WebStorm and resize it to the left two-thirds
tell application "WebStorm"
activate
say "Finally, your development environment" using "Oliver"
delay 6
end tell
tell application "System Events"
key code 123 using {option down, control down, command down}
end tell
-- launch iTerm and resize it to the right third and launch Harbor
tell application "iTerm"
activate
delay 1
set the bounds of front window to {1920, 0, 2560, 770}
end tell
tell application "System Events"
keystroke "hbh"
key code 36
end tell
delay 3
tell application "Google Chrome" to activate
tell application "System Events"
keystroke "c" using {option down, control down, command down}
end tell
delay 3
say "You're all set." using "Oliver"
@stevensacks
Copy link
Author

This script leverages an OSX Window Management tool called SizeUp to move/resize windows because many apps cannot be moved/resized using set the bounds of front window and it just throws an error when you try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment