forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslack-open-workspace-by-name.applescript
executable file
·51 lines (39 loc) · 1.42 KB
/
slack-open-workspace-by-name.applescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/osascript
# Dependency: This script requires Slack to be installed: https://slack.com/
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Open Workspace by Name
# @raycast.mode silent
# Optional parameters:
# @raycast.icon images/slack-logo.png
# @raycast.packageName Slack
# @raycast.argument1 { "type": "text", "placeholder": "Name", "optional": true }
# Documentation:
# @raycast.author Jakub Lanski
# @raycast.authorURL https://github.com/jaklan
on run argv
### Configuration ###
# Delay time before triggering the click (used only when Slack needs to be initialized)
set clickDelay to 5
### End of configuration ###
if application "Slack" is running then
do shell script "open -a Slack"
else
do shell script "open -a Slack"
delay clickDelay
end if
tell application "System Events" to tell process "Slack"
if item 1 of argv = "" then
click menu item 1 of menu 1 of menu item "Workspace" of menu 1 of menu bar item "File" of menu bar 1
else
set workspaces to name of menu items of menu 1 of menu item "Workspace" of menu 1 of menu bar item "File" of menu bar 1
set workspaces to items 1 through -8 of workspaces
repeat with workspace in workspaces
if workspace contains item 1 of argv then
click menu item workspace of menu 1 of menu item "Workspace" of menu 1 of menu bar item "File" of menu bar 1
exit repeat
end if
end repeat
end if
end tell
end run