First world problems. Often I am working on my Mac mini but then move to the MacBook. As a result of this Outlook and Teams are running on the Mac, and I don’t want. Mainly coz I don’t want to quit for the day and then open the Mac mini for any non-work tasks and then get sucked into work again (a manufacturing defect: if I see an email or Teams message I have a compulsion to action upon it rather than leave it for later ☺️).
Anyways, here’s what I do. SSH from the MacBook to the Mac mini and then run:
1 2 |
osascript -e 'quit app "Micrsooft Outlook"' osascript -e 'quit app "Micrsooft Teams"' |
This needs a one time setup on the Mac mini because the first time I run this I get two prompts like these (below screenshot is the second of these):
Interesting that it says iTerm. That’s what I am using on the MacBook to connect to the Mac mini, but how does the mini know that? Dunno.
Neat thing is the quit command gracefully quits it, rather than killing the process. Which is what I want.
I get the name of the application from what’s shown in the menu bar. Example:
I had found the following code which lists all the running applications:
1 2 3 |
osascript -e 'tell application "Finder" get the name of every process whose visible is true end tell' |
But the name returned by that seems to be different. For instance, while it names Word, Excel, Outlook etc. correctly, it names Teams as “MS Teams” and that doesn’t work with the quit command above.
When in doubt the following lets me test if a name I have is the correct one or not:
1 |
osascript -e 'id of app "MS Teams"' |
If this returns an error, like it did for “MS Teams” I know the name is wrong. (This is important because the quit command doesn’t give any output or errors, and while I know the names for Teams and Outlook I also need to have a way of finding the names of other apps if I wish to close them at some point).