@@ -39,19 +39,6 @@ function isLiveFocused()
3939 return false
4040end
4141
42- -- Search for a running instance of Live
43- --
44- -- Uses similar fallback to isHsAppObjLive() but doesn't rely on
45- -- it because APIs are slightly different. Like isHsAppObjLive(),
46- -- we're relying on exact matching.
47- function getLiveHsAppObj ()
48- local hsAppObj = hs .application .find (targetBundle )
49- if hsAppObj == nil then
50- hsAppObj = hs .application .find (targetName , true , true )
51- end
52- return hsAppObj
53- end
54-
5542function getLiveVersion (str )
5643 local infoPlistPath = string.format (" %s/Contents/Info.plist" , str )
5744 if ioIsFilePresent (infoPlistPath ) == true then
@@ -83,6 +70,27 @@ function getLiveVersion(str)
8370 , 10 )
8471end
8572
73+ -- Search for a running, preferably in-focus, instance of Live
74+ --
75+ -- Uses similar fallback to isHsAppObjLive() but doesn't rely on
76+ -- it because APIs are slightly different. Like isHsAppObjLive(),
77+ -- we're relying on exact matching.
78+ function getLiveHsAppObj ()
79+ local hsAppObj = hs .window .focusedWindow ():application ()
80+ if isHsAppObjLive (hsAppObj ) == false then
81+ hsAppObj = hs .application .find (targetBundle )
82+ end
83+ if hsAppObj == nil then
84+ hsAppObj = hs .application .find (targetName , true , true )
85+ end
86+ if hsAppObj ~= nil then
87+ print (string.format (" getLiveHsAppObj(): Found instance of Live %s" , getLiveVersion (hsAppObj :path ())))
88+ else
89+ print (" getLiveHsAppObj(): Unable to find running Live instance" )
90+ end
91+ return hsAppObj
92+ end
93+
8694-- Creates a table of strings consisting of valid Live menu entries
8795-- (these include children, which findMenuItem may not necessarily
8896-- include)
0 commit comments