APPS: AbleSet on the Tracks Mac watched; hold and auto-fix open it minimized
The user keeps AbleSet open (minimized) so ProdDash shows it. mac_start gets a Minimized option: open -g, then once the program has a window, System Events minimizes it. Tested live: quit AbleSet, APPS showed ABLESET NOT RUNNING within seconds, the hold reopened it with its window minimized. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+15
-2
@@ -99,6 +99,16 @@ ABLETON_SET = ("L=$(ls -td ~/Library/Preferences/Ableton/Live*/ | head -1); S=$(
|
||||
"| grep -v '/Templates/' | tail -1 | sed -E 's/^.*Loading document \"(.*)\"[^\"]*$/\\1/'); ")
|
||||
|
||||
|
||||
def mac_minimize(process, wait=20):
|
||||
"""Once the program has a window (up to `wait` s), minimize every window it has (System Events: osascript
|
||||
has Accessibility on the computer)."""
|
||||
ax = "tell application \"System Events\" to %s process \"%s\"" % ("%s", str(process).replace('"', ''))
|
||||
count = q(ax % "count windows of")
|
||||
mini = q((ax % "tell") + " to set value of attribute \"AXMinimized\" of every window to true")
|
||||
return ("i=0; while [ $i -lt %d ]; do sleep 1; i=$((i+1)); n=$(osascript -e %s 2>/dev/null); "
|
||||
"if [ \"${n:-0}\" -gt 0 ]; then osascript -e %s >/dev/null 2>&1; break; fi; done;" % (wait, count, mini))
|
||||
|
||||
|
||||
def ableton_open(app):
|
||||
return "if [ -n \"$S\" ] && [ -f \"$S\" ]; then %s; else %s; fi" % (mac_open(app, arg="\"$S\""), mac_open(app))
|
||||
|
||||
@@ -126,9 +136,12 @@ TEMPLATES = {
|
||||
"os": "mac", "start_only": True,
|
||||
"params": [P_HOST, ("process", "Process name", "As pgrep sees it (Activity Monitor's process name).", "str", None),
|
||||
("app", "App to open", "Its name, the full /Applications/... path, or $APP with 'newest of' below.", "str", None),
|
||||
("newest_of", "Newest of", "A pattern like /Applications/ProPresenter*.app: the newest installed version opens.", "str", "")],
|
||||
("newest_of", "Newest of", "A pattern like /Applications/ProPresenter*.app: the newest installed version opens.", "str", ""),
|
||||
("minimized", "Minimized", "Open it in the background and minimize its window (AbleSet: open, out of the way).", "bool", False)],
|
||||
"render": lambda p, cfg: ("pgrep -xq %s || { %s%s; }" % (q(p["process"]), newest_app(p["newest_of"]), mac_open("$APP"))
|
||||
if p.get("newest_of") else "pgrep -xq %s || %s" % (q(p["process"]), mac_open(p["app"]))),
|
||||
if p.get("newest_of") else
|
||||
"pgrep -xq %s || { %s; %s }" % (q(p["process"]), mac_open(p["app"], background=True), mac_minimize(p["process"]))
|
||||
if p.get("minimized") else "pgrep -xq %s || %s" % (q(p["process"]), mac_open(p["app"]))),
|
||||
"suggest": lambda p, cfg: "start %s if it is not running" % p["app"],
|
||||
},
|
||||
"mac_restart": {
|
||||
|
||||
Reference in New Issue
Block a user