I am attempting to set various Google Chrome preferences via a script (on both OS X and Windows). I can successfully set a number of preferences, and add bookmarks, by editi
A solution that is working for Chromium and Chrome on Ubuntu can be found here:
https://github.com/andreashuber69/os-setup/blob/master/common/reset-browser-preferences
Besides setting the default search provider, the linked script further customizes Chromium/Chrome to my liking. For Chrome, the part relevant to the question goes like this:
# Modify the preferences relevant to the default search provider
cat ~/.config/google-chrome/Default/Preferences | jq '.default_search_provider_data.template_url_data={ "keyword": "duckduckgo.com", "short_name": "DuckDuckGo", "suggestions_url": "https://duckduckgo.com/ac/?q={searchTerms}&type=list", "url": "https://duckduckgo.com/?q={searchTerms}&t=canonical" }' >adapted-preferences.json
mv adapted-preferences.json ~/.config/google-chrome/Default/Preferences
This simply adds a new entry to the list of search engines and sets it as default. If you want to select an existing one, things are little more complicated (see script for details). The above requires the package jq, which is not present out of the box on Ubuntu.
Contrary to other posts, it seems no longer possible to set the default in the meta table. It must be done through the Preferences file as shown above.