forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathferdi-open-service-by-name.applescript
executable file
·51 lines (39 loc) · 1.33 KB
/
ferdi-open-service-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 Ferdi to be installed: https://getferdi.com/
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Open Service by Name
# @raycast.mode silent
# Optional parameters:
# @raycast.icon images/ferdi.png
# @raycast.packageName Ferdi
# @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 Ferdi needs to be initialized)
set clickDelay to 5
### End of configuration ###
if application "Ferdi" is running then
do shell script "open -a Ferdi"
else
do shell script "open -a Ferdi"
delay clickDelay
end if
tell application "System Events" to tell process "Ferdi"
if item 1 of argv = "" then
click menu item 7 of menu 1 of menu bar item "Services" of menu bar 1
else
set serviceNames to name of menu items of menu 1 of menu bar item "Services" of menu bar 1
set serviceNames to items 7 through -1 of serviceNames
repeat with serviceName in serviceNames
if serviceName contains item 1 of argv then
click menu item serviceName of menu 1 of menu bar item "Services" of menu bar 1
exit repeat
end if
end repeat
end if
end tell
end run