-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathiTMW - Detect Phone.applescript
More file actions
executable file
·52 lines (51 loc) · 1.77 KB
/
iTMW - Detect Phone.applescript
File metadata and controls
executable file
·52 lines (51 loc) · 1.77 KB
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
52
on adding folder items to this_folder after receiving added_items
try
set pref to do shell script "/usr/bin/defaults read com.itmw.itmw phoneDetected"
set phonedetected to pref as number
on error
return
end try
if phonedetected = 1 then return
try
set musicpath to do shell script "/usr/bin/defaults read com.itmw.itmw musicPath | /usr/bin/sed 's/\\\\\\\\/\\\\/'"
set dir to do shell script "/bin/ls -d " & musicpath
on error
return
end try
if dir = "" then return
if dir contains return then return
set phonepath to POSIX file dir as string
tell application "Finder"
repeat with x in added_items
if disk of folder phonepath = disk of x then
if phonedetected = 2 then
tell me to set sync to choose from list {"Unmount", "Open Image Capture", "Open iPhoto", "Synchronize"} with title "iTuneMyWalkman" with prompt "iTuneMyWalkman has detected the phone. What do you want to do?" with multiple selections allowed
if sync = false then return
if sync contains "Unmount" then
eject disk of x
return
end if
if sync contains "Synchronize" then
my openapp()
end if
if sync contains "Open Image Capture" then open application file id "icac"
if sync contains "Open iPhoto" then open application file id "iPho"
else if phonedetected = 3 then
my openapp()
end if
end if
end repeat
end tell
end adding folder items to
-- This method is used to hide the tell block from Xcode during compile time.
-- Otherwise the compiling would fail, if the application is not found.
on openapp()
do shell script "/usr/bin/osascript -e \\
'tell application \"iTuneMyWalkman\"
launch
activate
ignoring application responses
tell button \"sync\" of window \"main\" to perform action
end ignoring
end tell'"
end openapp