-
Notifications
You must be signed in to change notification settings - Fork 10
/
flappy-dird.applescript
41 lines (32 loc) · 1.56 KB
/
flappy-dird.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
property projectPath : ""
set myAlias to path to me
set myPath to POSIX path of myAlias -- Converts alias to a Unix style path
-- Find the last occurrence of "/" (slash)
set lastSlash to the offset of "/" in (reverse of characters of myPath) as string
-- Remove the filename from the path
set projectPath to text 1 thru -((lastSlash + 1)) of myPath & "/"
property buf2Path : projectPath & "buf2"
-- A subroutine to set Finder window's target
on setFinderTarget(buf)
tell application "Finder" to set target of front Finder window to (projectPath & buf as POSIX file)
tell application "Finder" to tell front window to update every item
end setFinderTarget
-- Main program starts here
set quotedProjectPath to quoted form of projectPath
set curBuf to do shell script quotedProjectPath & "flap.py init"
setFinderTarget("buf2") -- Avoid caching old filenames
setFinderTarget(curBuf)
do shell script quotedProjectPath & "flap.py await"
repeat while true -- equivalent to '1 = 1'
set shouldContinue to "continue"
repeat while shouldContinue = "continue"
tell application "Finder" to set selectedItems to selection
set curBuf to do shell script quotedProjectPath & "flap.py tick " & (number of selectedItems)
setFinderTarget(curBuf)
set shouldContinue to do shell script quotedProjectPath & "flap.py sleep"
end repeat
do shell script quotedProjectPath & "flap.py await"
set curBuf to do shell script quotedProjectPath & "flap.py init"
setFinderTarget("buf2") -- Avoid caching old filenames
setFinderTarget(curBuf)
end repeat