I have a dual backup system: Carbon Copy Cloner (CCC) clones (including nightly), Time Machine for file versioning and Backuploupe to facilitate the management of Time Machine (I don't like the time machine interface).
There is a conflict between backuploupe and CCC: when I run CCC, backuploupe has to be closed (quit)
I wrote the macro below, which works. Now I have to write a macro which says that if CCC is not activated, backuploupe should be activated (or launched since it was closed?).
It would be easy to write a second macro to do the opposite.
Solely in terms of elegance, would it be possible to include everything in one macro, perhaps with an if otherwise action as I wrote below. My problem with the if otherwise solution is how to define the macro trigger. It's as if I want KBM to continuously monitor the system to see if CCC is active or not.
thanks very much for your time and help
If I understand you right, you want to have BL2's activation controlled by whether CCC is running or not, with the latter's activation and deactivation acting as the triggers? I don't have either of those apps, but I believe this macro should work once you adapt it to your own apps:
Quit:Launch App When Quitting:Launching Other App.kmmacros (3.9 KB)
Just change all instances of SuperDuper! to CCC (and the text condition to "contains Carbon" or something else that reflects how CCC's name is displayed when running it) and TextEdit to BL2 and see if that doesn't do the trick.
EDIT: Now that I look again, it seems you're already most of the way there with your If/Else action. All you should need is the other application trigger that fires when CCC quits.
thanks very much for your lightning speed reply !
You taught me how to better use triggers. In this case the possibility of having 2 triggers at the same time.
The following works. Does it seem OK ?
I am very grateful for your time writing a macro, but have difficulty understanding the first action. What is switch of text ? Where did you find %Application%1% ? You did not define the variable and I don't see it in the list of tokens
I would like to better understand the action you use and how the variable is defined.
thanks again very much
No problem. Your macro looks fine, though I wonder if "deactivates" rather than "quits" will achieve the effect you want, since deactivating CCC isn't the same thing as quitting it, and could conceivably lead to scenarios in which it's backing up in the background while BL2 is still running. But as I said, I don't have those apps, so if the "deactivates" trigger makes the macro behave how you want, that's all that matters.
Application%1% token is a token that provides the name of the frontmost application. In this context, it's just another way of telling KM "If this application is at the front". I'm not sure in which list of tokens you looked, but it shows up in the Insert Token by Name action:
And in this menu:
As for the Switch action action, it's an alternative to If Then Else that enables branching scenarios for multiple possible values. It lets you do things like tell KM "If variable X is 1, do this. If it's 2, do this. If it's 3, do this." and so on, without having to nest several If Then Else actions inside one another. It may not be as immediately intuitive as If Then Else, but I've found that once you have a use case for it and try it in practice, it quickly clicks and its utility thereafter is readily apparent.
As well as the menus in Keyboard Maestro (including the Edit ➤ Insert Token menu), the tokens are listed on the wiki at:
thank you Peter. I added the list to my KBM notes.
thank you for letting me know about the switch action, a more elegant if then else. I will use it next time I have an if then else problem. I prefer to take the more cerebral path.
Here is the KBM doc definition of activation
The Application trigger allows you to execute a macro when an specified application (or any application) does any of the following:
An application Activates when it comes to the foreground, and deactivates when another application comes to the foreground.
You could use a trigger like this to simulate workspaces by automatically setting up an application the way you want when you launch it, or you could clean up after an application when you quit.
I am now confused, and realize that I did not consider the 3rd possibility, which is CCC running in the background which it does 99% of the time. It is only the frontmost application during the 30 seconds when I trigger the backup. With scheduled backups CCC is never the frontmost application. BL2 runs nearly exclusively in the background, so the notion of being 'active' also does not apply.
basically the algorithm should be:
- if CCC is running (foreground or background) ie actively backing up to an external drive, the BL2 app should quit.
- when CCC quits (and only when CCC quits) should BL2 launch (it works in the background).
My conclusion is that neither of our macros work in that context. I have to write another macro.
Do you know if there are triggers or actions which detect if an app is running (foreground or background) ?
There is an is running trigger**** but it is associated with a timer.
thanks again very much
You should quit backuploupe when CCC launches, and launch backuploupe when CCC quits.
The Application trigger can trigger when an application launches or quits.
thank you Peter.
I am writing a follow up question because I think that it is an interesting problem from a KBM point of view, and perhaps of interest to other users.
Your solution came to mind, but the problem is a bit more complicated.
CCC is always launched, and creates clone backups sometimes manually, sometimes scheduled (in the background).
In that context, I think that we should forget about the active and running triggers.
To make a long story short, I want to quit backuploupe when CCC is actively writing to an external backup drive of which I have 2: one called Nightly Backup and the other Untitled.
Is there a way to use 'actively reading/writing to an external drive' as a trigger to quit backuploupe, and launch it when the writing stops?
thanks very much
There's a trigger that runs when an external drive is mounted or unmounted, but not for reading or writing. However, if you poke around in CCC's advanced options:
you can see that CCC itself lets you run shell scripts before and after a copy:
So what I would do is create two very simple shell script files, one to quit BL2 and one to launch it, and have CCC run them as appropriate. To make a shell script file that quits BL2, create a plain text file that just says
osascript -e 'quit app "BackupLoupe 2"'
To make one that launches BL2, all you have to put is
open "/Applications/BackupLoupe 2.app"
You'll need to make sure the name and path of the app is correct for your system, but that should get you started. From there, you can follow instructions on how to make the resulting script files executable here, and then just add them as appropriate to CCC's options.
fantastic solution !! thanks very much.
I also want to say that I greatly appreciate all the time and effort you put into making crystal clear illustrations. Which image annotation app do you use ?
You're quite welcome, but it's really not much trouble. I use an app called, appropriately, Annotate, that makes it pretty easy: https://apps.apple.com/us/app/annotate-capture-and-share/id918207447?mt=12
I got it from the app store today. Thank you