fix(launcher): replace fixed post_delay with frontmost poll across all launch profiles
`open -a App` returns immediately; a fixed delay is unreliable for cold starts. Each post_script now polls every 500 ms (up to 7.5 s) until the target process is frontmost before firing the automation keystroke. Keynote polls document count instead of frontmost since start(front document) requires the file to be loaded. Mac profiles: post_delay_ms 2000 → 1000. Win/Parallels profiles: 3000 → 1500. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -57,10 +57,21 @@ function make_vlc_mirror_profile(): LaunchProfile {
|
||||
app: 'VLC',
|
||||
display_mode: 'mirror',
|
||||
open_cmd: 'open -a "VLC" "{{path}}"',
|
||||
post_delay_ms: 1500,
|
||||
post_delay_ms: 1000,
|
||||
// Poll until VLC is frontmost before sending Cmd+F. A fixed delay is unreliable because
|
||||
// `open -a VLC` returns immediately (just fires an Apple Event) — VLC cold-start on a
|
||||
// loaded conference Mac can take 3-5 seconds before the window is visible and interactive.
|
||||
// Polling (15 × 0.5 s = up to 7.5 s after the initial wait) fires as soon as VLC is ready.
|
||||
post_script: `tell application "VLC"
|
||||
activate
|
||||
end tell
|
||||
repeat 15 times
|
||||
delay 0.5
|
||||
tell application "System Events"
|
||||
if frontmost of process "VLC" is true then exit repeat
|
||||
end tell
|
||||
end repeat
|
||||
delay 0.3
|
||||
tell application "System Events"
|
||||
tell process "VLC"
|
||||
keystroke "f" using command down
|
||||
@@ -73,10 +84,17 @@ const POWERPOINT_MAC_EXTEND_PROFILE: LaunchProfile = {
|
||||
app: 'Microsoft PowerPoint',
|
||||
display_mode: 'extend',
|
||||
open_cmd: 'open -a "Microsoft PowerPoint" "{{path}}"',
|
||||
post_delay_ms: 2000,
|
||||
post_delay_ms: 1000,
|
||||
post_script: `tell application "Microsoft PowerPoint"
|
||||
activate
|
||||
end tell
|
||||
repeat 15 times
|
||||
delay 0.5
|
||||
tell application "System Events"
|
||||
if frontmost of process "Microsoft PowerPoint" is true then exit repeat
|
||||
end tell
|
||||
end repeat
|
||||
delay 0.3
|
||||
tell application "System Events"
|
||||
tell process "Microsoft PowerPoint"
|
||||
keystroke return using command down
|
||||
@@ -88,9 +106,20 @@ const KEYNOTE_MAC_EXTEND_PROFILE: LaunchProfile = {
|
||||
app: 'Keynote',
|
||||
display_mode: 'extend',
|
||||
open_cmd: 'open -a "Keynote" "{{path}}"',
|
||||
post_delay_ms: 2000,
|
||||
post_delay_ms: 1000,
|
||||
// Keynote uses `start (front document)` which requires the document to actually be loaded —
|
||||
// polling frontmost is not enough here. Poll document count instead.
|
||||
post_script: `tell application "Keynote"
|
||||
activate
|
||||
end tell
|
||||
repeat 20 times
|
||||
delay 0.5
|
||||
tell application "Keynote"
|
||||
if (count of documents) > 0 then exit repeat
|
||||
end tell
|
||||
end repeat
|
||||
delay 0.3
|
||||
tell application "Keynote"
|
||||
start (front document)
|
||||
end tell`
|
||||
};
|
||||
@@ -99,10 +128,17 @@ const LIBREOFFICE_MAC_EXTEND_PROFILE: LaunchProfile = {
|
||||
app: 'LibreOffice',
|
||||
display_mode: 'extend',
|
||||
open_cmd: 'open -a "LibreOffice" "{{path}}"',
|
||||
post_delay_ms: 2000,
|
||||
post_delay_ms: 1000,
|
||||
post_script: `tell application "LibreOffice"
|
||||
activate
|
||||
end tell
|
||||
repeat 15 times
|
||||
delay 0.5
|
||||
tell application "System Events"
|
||||
if frontmost of process "soffice" is true then exit repeat
|
||||
end tell
|
||||
end repeat
|
||||
delay 0.3
|
||||
tell application "System Events"
|
||||
tell process "soffice"
|
||||
key code 96
|
||||
@@ -114,10 +150,17 @@ const ACROBAT_MAC_MIRROR_PROFILE: LaunchProfile = {
|
||||
app: 'Adobe Acrobat Reader DC',
|
||||
display_mode: 'mirror',
|
||||
open_cmd: 'open -a "Adobe Acrobat Reader DC" "{{path}}"',
|
||||
post_delay_ms: 2000,
|
||||
post_delay_ms: 1000,
|
||||
post_script: `tell application "Adobe Acrobat Reader DC"
|
||||
activate
|
||||
end tell
|
||||
repeat 15 times
|
||||
delay 0.5
|
||||
tell application "System Events"
|
||||
if frontmost of process "AdobeReader" is true then exit repeat
|
||||
end tell
|
||||
end repeat
|
||||
delay 0.3
|
||||
tell application "System Events"
|
||||
tell process "AdobeReader"
|
||||
keystroke "l" using command down
|
||||
@@ -131,10 +174,17 @@ const POWERPOINT_WIN_EXTEND_PROFILE: LaunchProfile = {
|
||||
app: 'Microsoft Office PowerPoint (Windows)',
|
||||
display_mode: 'extend',
|
||||
open_cmd: 'open -a "Microsoft Office PowerPoint" "{{path}}"',
|
||||
post_delay_ms: 3000,
|
||||
post_delay_ms: 1500,
|
||||
post_script: `tell application "Microsoft Office PowerPoint"
|
||||
activate
|
||||
end tell
|
||||
repeat 15 times
|
||||
delay 0.5
|
||||
tell application "System Events"
|
||||
if frontmost of process "Microsoft Office PowerPoint" is true then exit repeat
|
||||
end tell
|
||||
end repeat
|
||||
delay 0.3
|
||||
tell application "System Events"
|
||||
key code 96
|
||||
end tell`
|
||||
@@ -144,10 +194,17 @@ const LIBREOFFICE_WIN_EXTEND_PROFILE: LaunchProfile = {
|
||||
app: 'LibreOffice (Windows)',
|
||||
display_mode: 'extend',
|
||||
open_cmd: 'open -a "LibreOffice" "{{path}}"',
|
||||
post_delay_ms: 3000,
|
||||
post_delay_ms: 1500,
|
||||
post_script: `tell application "LibreOffice"
|
||||
activate
|
||||
end tell
|
||||
repeat 15 times
|
||||
delay 0.5
|
||||
tell application "System Events"
|
||||
if frontmost of process "soffice" is true then exit repeat
|
||||
end tell
|
||||
end repeat
|
||||
delay 0.3
|
||||
tell application "System Events"
|
||||
tell process "soffice"
|
||||
key code 96
|
||||
@@ -159,10 +216,17 @@ const ACROBAT_WIN_MIRROR_PROFILE: LaunchProfile = {
|
||||
app: 'Acrobat Reader (Windows)',
|
||||
display_mode: 'mirror',
|
||||
open_cmd: 'open -a "Acrobat Reader Windows" "{{path}}"',
|
||||
post_delay_ms: 3000,
|
||||
post_delay_ms: 1500,
|
||||
post_script: `tell application "Acrobat Reader Windows"
|
||||
activate
|
||||
end tell
|
||||
repeat 15 times
|
||||
delay 0.5
|
||||
tell application "System Events"
|
||||
if frontmost of process "Acrobat Reader Windows" is true then exit repeat
|
||||
end tell
|
||||
end repeat
|
||||
delay 0.3
|
||||
tell application "System Events"
|
||||
key code 108 using control down
|
||||
end tell`
|
||||
|
||||
Reference in New Issue
Block a user