Macro to Replace Chrome Actions with Front Browser Actions?

I'm no good at writing macros that affect Keyboard Maestro itself, so before I embark on replacing hundreds of actions by hand, I thought I'd ask:

Does anyone have a macro to replace Chrome-centric actions with actions that work with other (not Safari) browsers?

Now that Google has come out of the closet as overtly evil, I'm trying to reduce my reliance on Google (Search, Chrome, etc.) and trying out Chromium-based browsers with privacy and security, like Brave, Vivaldi, and so on. I'd like to be able to use my many macros that open browser windows and tabs as part of the testing, even if I have to go back to Chrome.

I'm not sure I fully understand the question, and I haven't used Chrome in a very long time, but many of those could be replaced by just executing the right actions in your browser of choice. That is, send the "New Tab" menu command to the browser. Or the "New Window" command, etc.

But there are a lot of Chrome actions in Keyboard Maestro; which ones are you using?

Also, the Open URL action can specify any application (that's capable of handling URLs) you want to choose.


Here's one example of a manual replacement (lower) of what I had previously (upper).

My point is that I already have a lot (a lot) of Chrome-centric actions within macros, and I'm hoping for a way to replace them with equivalent actions without manually doing them all.

Oh, I missed that you were trying to automate this; sorry! I think there have been some posts on similar subjects here over the years, but I couldn't find any in a quick search. I think it'd be very complicated, though, because you'd have to search the XML file of your macros for strings of text, and then replace with new XML for the replacement actions.

But anything approaching that scope of work is well beyond my skill level, sorry!


It's not a perfect solution, but you can change the browser that the Chrome-related actions target by setting two hidden preferences -- see "Change which Chrome-based Browser will be targeted" section of the manual's Preferences Set by Command Line section.

At least that way you test a single alternative Chromium-based browser at a time without having to change your macros.

1 Like

This sounded like a great idea, but it didn't work. Following those instructions, issuing the following

defaults write com.stairways.keyboardmaestro.engine AppleScriptGoogleChromeBundleID -string "com.brave.Browser"
defaults write com.stairways.keyboardmaestro.engine BrowserGoogleChromeName -string "Brave Browser"

intro Terminal resulted in all Google Chrome actions in KM being converted to Safari actions, and then they don't work. Worse, I can't get any browser actions to work at all now after several restarts and issuing the "# ~~~ Restore to Google Chrome ~~~" commands in Terminal. Now KM won't do anything with a browser.

@peternlewis Help?

Reverting via File > Revert Macros doesn't restore the Chrome-now-Safari actions, even when reverting to more than a week back. It's as if KM has replaced all the Chrome actions via search and replace with Safari actions. Not exactly what I wanted.

How can I get macros back to before Safari replaced everything Chrome replacing the Chrome string with Brave?

I don't know what happened, but setting those preferences didn't do it.

This is what happens after the change:

Deleting them restores it:

defaults delete com.stairways.keyboardmaestro.engine AppleScriptGoogleChromeBundleID
defaults delete com.stairways.keyboardmaestro.engine BrowserGoogleChromeName

The commands only affect the AppleScript code that is used, and the display.

Did you write to other preferences? Perhaps you made changes to the equivalent BrowserSafariName? That would explain why reverting your macros makes no difference.

You can also look at the XML of the action.

The Safari ones have WebBrowser key set to Safari.

I understand that that's not supposed to happen, but it did.

Update: reverting to last week's macros three times via File > Revert Macros, and restarting in between, solved the Safari-replaced-Chrome Actions in all existing macros. They are back to Chrome actions now.

I'm back to square one with trying to replace Chrome with Brave on existing actions.

Given that an unintentional action occurred--Safari replaced Chrome in existing actions, which is what I want to happen but with a different browser than Safari--can you help me with how to deliberately replace existing Chrome actions with Brave actions?

A related but different problem occurred when I tried to reset Safari. I'll post about that under a different topic.

I really doubt that.

Delete the preferences and restart Keyboard Maestro Engine and Keyboard Maestro.

defaults delete com.stairways.keyboardmaestro.engine AppleScriptSafariBundleID
defaults delete com.stairways.keyboardmaestro.engine BrowserSafariName 
defaults delete com.stairways.keyboardmaestro.engine AppleScriptSafariName 
defaults delete com.stairways.keyboardmaestro.engine AppleScriptGoogleChromeBundleID
defaults delete com.stairways.keyboardmaestro.engine BrowserGoogleChromeName 
defaults delete com.stairways.keyboardmaestro.engine AppleScriptGoogleChromeName 

I've just tested here with a brand new Brave install -- and everything worked as advertised:


So it does look like you've got something else going on.

Yeah, KM was definitely misbehaving. Reverting all macros a few times and then resetting all the browser preferences per Peter's instructions eventually fixed it all. (I had actually documented my step-by-step actions that lead to the problems, and then the same for fixing it, [I'm a software book author, so I'm in the habit of writing step-by-steps] but I didn't want to clutter this thread with them.)

Is that a new action or were you able to get Brave as an action that replaced an existing Chrome action?

I was able to get Brave to replace Chrome for new actions, but not for existing actions, which I'm hoping to not have to rebuild one by one. I have a lot of New Tab with specific URLs for weekly research (about 24 tabs across two subjects/tasks), which I mostly automate by listing them in a variable and doing a For Each, but then I've got another 30 or so New Window or New Tab with specific URL actions as standalones I'd have to rebuild via New Action, copy, paste, disable old Chrome action.

Instantly effective, and working on existing macros' actions without me having to do anything but the Terminal commands. Note that the Editor UI won't update an existing action unless you interact with it, for example by switching to another macro and back.

All that is as I would expect. The action itself contains no information about the browser to be used (the XML remains the same). As I understand it, the action is simply "Do this action in the default Chromium browser" -- the Engine determines the browser to use from the AppleScriptGoogleChromeBundlleID plist entry and targets the osascript command appropriately. And the Editor UI is built on the fly from the action's XML, the default action name based on the BrowserGoogleChromeName plist entry.

So everything is mediated by the plist entries, no need to update previously-added actions (except the action's name, if you've customised it).

And yes, that means you can set:

defaults write com.stairways.keyboardmaestro.engine BrowserGoogleChromeName -string "Chrome, although it sucks,"

...and your action's default name will become:


1 Like