forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.applescript
executable file
·46 lines (39 loc) · 1.25 KB
/
configure.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
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Configure
# @raycast.mode compact
# Optional parameters:
# @raycast.icon images/denon_logo.png
# @raycast.argument1 { "type": "text", "placeholder": "Denon AVR IP" }
# @raycast.argument2 { "type": "text", "placeholder": "Method (Classic or Modern)" }
# @raycast.packageName Denon AVR
# Documentation:
# @raycast.description Helperscript to configure Denon AVR Script Commands
# @raycast.author Rediwed
# @raycast.authorURL github.com/Rediwed
on run argv
try
checkAlive(item 1 of argv)
writeIP(item 1 of argv)
setMethod(item 2 of argv)
log "Configuration success!"
on error err_msg
tell me to error "An error has occured: " & err_msg
end try
end run
on checkAlive(ip_address)
try
do shell script "ping -c 1 " & ip_address
on error
tell me to error "Ip-address " & ip_address & " is incorrect, please adjust"
end try
end checkAlive
on writeIP(ip_address)
do shell script "defaults write com.Rediwed.DenonAVR ip_address " & ip_address
return
end writeIP
on setMethod(Method)
set Method to (do shell script "echo " & (quoted form of Method) & " | tr '[:upper:]' '[:lower:]'")
do shell script "defaults write com.Rediwed.DenonAVR method " & Method
end setMethod