Here's a version that doesn't remain running, and it's incredibly easy to add more apps:
app-Terminal Macros.kmmacros (40 KB)
There are two macros in this set:
Launch screen-size window processes
: The macro that launches the apps you want to run in filled-screen mode. Here's what it looks like:
Check process status
: A macro that checks to see if a filled-screen app is running.
Note: Do not enable the Check process status
macro when you import these two macros; it's enabled and disabled by the macros themselves. You do need to enable the other one, though.
How to use
This solution works for any app you set up in the Launch screen-size window processes
macro. It's currently set to handle both btop
and castero
, but adding another app is this simple:
- Add a new Typed String Trigger for the app you want to run. Assign it a shortcut with one non-meaningful first letter (I used 'Z', but it can vary by shortcut, i.e.
bbtop
and ccastero
would be fine), followed by the actual name of the app you want to run.
And that's it, there is no step two.
How it works
The macro strips off the leading character and saves the app name to a global variable, launches the app, saves the current window size, and then resizes the Terminal window to fill the screen. It then pauses to make sure the app has launched, and then enables the process check macro.
The process check macro runs every second (when Terminal is frontmost), and all it does is this:
The process check macro sits idle until the Terminal's window title changes. Once that happens, it checks if there's a stored Terminal window size and the Terminal title does not contain the name of the app.
If both conditions are true, it means the fill-the-screen app has terminated, so the Terminal window size and location are restored, the two global macros are deleted, and then the check process macro disables itself—so it's only active when you have a filled-screen app running.
This solution should avoid the timeout issues you were experiencing, as there's no long-running macro: As soon as you launch a listed process, the screen resizes and the macro quits. And there's nothing running every time you resize a window.
Yes, there's a new macro that runs every second, but in my testing, it takes under 0.04 seconds to run, and I couldn't see any CPU hit at all while it was running.
This is the thing I love about Keyboard Maestro: There are so many ways to solve a problem!
-rob.