Trying to Figure Out How to Make System Preferences Changes When Starting and Stopping a Program


I use Ableton Live 10 on my Mac (Mac Pro - trashcan - late 2013 model - Mojave).

To use it effectively, I need to turn off the Time Machine "back up automatically". And I also need to turn off the screen saver so it doesn't start after 10 minutes. I would like to set it to never

Then, when I close Ableton Live, I would like to reverse the above things so Time Machine is turned on again and the Screen Saver is set to 10 minutes.

Below is what I have tried but can't get it to work. Peter suggested I post here. He said I need to find an alternative way to toggle the preferences and that maybe someone who knows more about driving the System Preferences can probably offer me some solutions.

I also use Alfred if that might be of help. And am pretty much a lightweight at this kind of thing.

This is what I've tried:

I set a new Macro that is triggered by an application, Ableton Live 10 Suite, Launches. Will execute the following Actions: Open Time Machine Preference Pane.

But there is nothing further I can select like - uncheck auto back up.

So it open the preferences pane, but how can I get it to uncheck auto backup, then close the pane.

Next, I can’t figure out how to make another action that stops the Desktop and Screensaver from starting after 10 minutes. I want that turned off when Ableton Live starts and I want it turned back on when I close Ableton Live.

Any thoughts or ideas are most welcomed.

Changing preferences in System Preferences has gotten trickier over recent versions of OS X, so I try to avoid it whenever possible.

I have two suggestions, both of which should be easily do-able in Keyboard Maestro, and neither of which involves touching System Preferences.

Time Machine


My first idea for Time Machine is a simple one: unmount the Time Machine drive/partition when 'Ableton Live 10 Suite' launches, and re-mount it when the app quits.

That will obviously prevent Time Machine from running, but it will only work if Time Machine backs up to a drive/partition which is not used by anything else.

A simple shell command should do it, something like

diskutil unmount MyTMdrive

should unmount the drive. (Replace MyTMdrive with the actual name that appears in /Volumes/, of course.)

Then something like

diskutil mount MyTMdrive

should bring it back.

(Be sure not to use diskutil eject which I believe means that you will need to physically disconnect/reconnect the drive to use it again.)


If you can't use the mount/unmount idea, then the next easiest way is to tell Time Machine to disable automatic backups using the tmutil command:

From man tmutil:


         Turn off automatic backups. Requires root privileges.

The 'root privileges' thing is a bit tricky. There are two ways around that:

Option A) The easiest way to get around it is to run an AppleScript which invokes a shell script:

do shell script "tmutil disable" with administrator privileges

and then you'll be prompted to enter your password each time you run the command.

Option B) I would find entering my password every time I had to do this annoying, so I would add tmutil to /etc/sudoers :

%admin ALL=NOPASSWD:/usr/bin/tmutil

that way I could run a shell script (not an AppleScript) in Keyboard Maestro) which did this:

sudo tmutil disable

without having to enter my administrator password.

Be careful editing /etc/sudoers. Use sudo visudo to make your changes.

Disable the Screen Saver

Disabling the screen saver is actually quite easy.

The trick is that you don't need to disable the screen saver… you just need to tell the computer not to let it start, which sounds like the same thing, but it’s slightly different.

The way to do that is with the caffeinate command. From man caffeinate:

 caffeinate creates assertions to alter system sleep behavior.  If no assertion flags are specified, caffeinate creates an assertion to prevent idle
 sleep.  If a utility is specified, caffeinate creates the assertions on the utility's behalf, and those assertions will persist for the duration of
 the utility's execution. Otherwise, caffeinate creates the assertions directly, and those assertions will persist until caffeinate exits.

 Available options:

 -d      Create an assertion to prevent the display from sleeping.

Preventing the display from sleeping also prevents the screen saver from being triggered (at least in my testing).

The key here is that in order for this to work with an app, you have to give it the full path to the app executable, not just the '.app' bundle.

For example, if I wanted to keep my Mac awake while I was using TextEdit, this would be wrong:

caffeinate -d "/Applications/"

but this would be right:

caffeinate -d "/Applications/"

(normally the app executable for "" is "" so you can adapt that for your app.)

Note that you don't technically need the "quotation marks" around the path, unless there are spaces or some other punctuation that might trip-up the shell, so I just used them to be safe.

Apps That Do This Too:

There was an app called "Caffeine" which people used for this, but it hasn't been updated in a long time.

Fortunately there are two free alternatives which are currently maintained:

  1. "Keeping You Awake" (

  2. "Amphetamine" (

"Amphetamine" has a specific feature to keep the Mac awake while an app is running. It also comes from the Mac App Store, so it has the advantage of being easily updated when new versions are released.

I hope this helps! Let me know if you run into trouble.



This was super helpful. Thank you!

Since it makes me nervous doing some of the deeper coding you talked about, here is what I did.

I have two Macros in Keyboard Maestro. One triggers when Ableton Live launches. It opens the System Preferences to the Time Machine page. All I have to do is to click the checkbox in front of Back Up Automatically. Not a big deal.

What I wish I could do is to have the macro pause until a mouse click happens (I have this running now) - then once the mouse is clicked, it shuts the preferences window down. Is that something that is easily possible. I found out how to open the window but don't see a way to close it. If there isn't an easy way, no big deal. This is still a terrific solution.

Then when Ableton Live is closed, it pops open the system pane again and I recheck the back up box. Just wish after ticking the box the window would close. But not a big deal if it isn't really easy.

Then, thanks to your suggestion, I installed Amphetamine and have it activate when Live starts and stop when I shut down Live. A perfect solution. I've tested it and it works great.

Now I don't have to remember to do this anymore - which I frequently forgot.

Again, this was super helpful. Thank you.

First, to answer your question: Yes! Look for a Keyboard Maestro action named "Manipulate a Window".

You can set that to close any window.

Or you could just tell Keyboard Maestro to quit System Preferences using "Quit a Specific Application".

Second: If you are going the route of opening the System Preferences window, you can also have Keyboard Maestro do the mouse click itself.

Actually, even better: don't use a mouse click at all! Once the System Preference pane is open, you can press 'tab' to select the checkbox and 'space' to toggle it.

You can have Keyboard Maestro do that for you entirely. Then you just have one Keyboard Maestro macro that you run before and after the app starts:

Toggle Time Machine.kmmacros (5.1 KB)

This is what I came up with.

You'll note that it doesn't have a trigger. You could make the trigger whenever your app launches or quits.

1 Like

This is fantastic. We're sooooo close.

I installed the script you sent, made the trigger when Ableton Live starts. And it works perfectly. It unchecks the box and closes the window.

Then I stalled the script again, changed it name. Set the trigger for when Ableton Live Quits. When it quits, the preferences for Time Machine opens, but it doesn't click the box. Then it closes after the 3 second delay.

To double check, I've opened the time machine preferences and it is not checked.

Any thoughts why it unchecks the box but won't check it?

A) You don't need to install the macro twice, you can just add two triggers, one for Ableton Live launches and one for Ableton Live quits.

B) Rather than using Keystrokes, we should use AppleScript to check/uncheck the box.

I've updated the macro to use AppleScript instead of keyboard commands.

I've also set it to activate whenever "Finder" quits or "Finder" launches. Change both of those to "Ableton Live" and you should be good to go.

Toggle Time Machine v2.kmmacros (6.2 KB)

1 Like

That did it!

I'm starting and stopping the program just to watch all this automated action happen. Feels like I'm a little kid with a new toy.

Thank you so much for your help!!!

1 Like

Awesome! I'm glad to help! And I learned a few things too.

Here's a pure-AppleScript way to do it: (*)

tell application "System Preferences"
	set the current pane to pane ""
end tell

tell application "System Events"
	tell process "System Preferences"
		click checkbox "Back Up Automatically" of window "Time Machine"
	end tell
end tell

delay 3

tell application "System Preferences"
end tell

You can change the delay 3 to anything, or just delete it. It only exists so you can see the change happen.

(* = Personally I still prefer using Keyboard Maestro to open System Preferences to the right Preference Pane because we can use "Pause Until" to make sure System Preferences is ready before we send the AppleScript command.)

1 Like

That is way beyond me. But from the looks of it, the other way looks easier. And the main thing is... it works perfectly.

This is such a help that you almost wouldn't believe it. If I forget to turn off the backup, and it starts while I'm recording, which it frequently did, it distorts the audio terribly. It has ruined hours of work.

This makes all the difference in the world.

Now you have me excited as to what else I might be able to automate.

Thank you again. That doesn't feel like nearly enough to say. You really made a difference for me.


You are quite welcome. Over the years I've received lots of help too, so I'm glad to be able to help others.

Once you get in to "the automation mindset" you will probably find lots of things you want to do.

I feel confident in saying that if you can't do them with Keyboard Maestro, then they can't be done, but most things can be done!


Hi tjluoma,

You helped me get script working that toggle's time machine on and off and keeps the screen from going off.

Here is a screen shot of the script:


One problem I still have is getting DropBox to pause it's syncing as well. Seems to me it should be possible as there is an option to pause syncing. But I can't seem to see that within Keyboard Maestro.

Look at this screen shot and you'll see what I mean:


Dropbox has a dropdown menu. A gear icon is on the upper right. (You'll see I drew an arrow to it.) When clicked it shows a "Pause Syncing" option.

What would be great is if I could add something to the script that pauses it upon starting Ableton Live and unpauses it when closing it?

Any way you might know how to do that?


Unfortunately, Dropbox is not scriptable. People have asked for it for years, but nothing has been added, so I wouldn't expect it will be.

You could try some kind of UI scripting with AppleScript or "click on found image" with Keyboard Maestro, but I've never found a reliable way of doing it.

I would simply quit Dropbox when Ableton launches and restart it when Ableton quits.

That would explain why I couldn't find it. :smile:

Thanks again. I'll just pause manually.

Hey Ken,

Well, we can't have that can we?

This is very brute-force, but it works.


Dropbox -- Toggle Sync On-Off.kmmacros (7.1 KB)

Hey Ken,

I didn't do my variable housekeeping in the last macro.

Normally I'd just replace it in that post with an updated version, but I'm posting both versions – so you and others can see how I'm doing that.


Dropbox -- Toggle Sync On-Off v1.01.kmmacros (7.8 KB)

Oh my goodness...

Chris I didn't realize this was for me. I saw it but somehow it didn't register.

This is amazing. Thank you.

Is there anyway to drag what you did there into what I have so it just adds this?

I'm going to try to put a screenshot here to show you what I have.


Hey Ken,

No, but you can download my macro, double-click it, and then copy & paste as desired.


Hey Chris,

I didn't realize it was downloadable. I'm learning lots. And have a long way to go. lol

I downloaded and it works great. It's super fast as well.

When I open the script, I can select the different parts of it and choose copy. But do I copy as text, as image or... not sure what to do or how to add it to mine.

What I'd like to do is to add it at the bottom of mine so that when I open Ableton Live, it fires off and when I close it, it fires off again to return things to normal.

Sorry for my questions, I'm just not sure how to add it to what I have.



I figured out how to change the trigger to the app starting and stopping, Now both processes fire off when I start and stop Ableton Live. So it's working and that's great,

The one you gave exists outside the other one. Not sure if it's possible to combine them. If it is, let me know when you can. If not, it is working.

This is really awesome. I'm excited that Keyboard Maestro does so much.


Hey Ken,

All you have to do is select the actions in my macro that you want and then copy.

Move to your macro.

Select the action you want to paste after and then paste.

You don't need to worry about how to copy – just press Cmd-C and then later Cmd-V when pasting.