I managed to change the default search engine from Bing to DuckDuckGo in Thunderbird 52.4.0 with an extremely convoluted workaround. I didn't like any of Thunderbird's presets, so I chose DuckDuckGo because although I never really want to search from Thunderbird, if I do accidentally search, I'd rather use a search engine that promises not to track me.
For this, you will need an instance of Firefox with the DuckDuckGo search engine (I used Firefox 58.0.1). I will use [TB profile]
to refer to your Thunderbird user profile directory, [FF profile]
to refer to your Firefox user profile directory, and [FF app]
to refer to your Firefox application folder.
First, we want to locate the ddg.xml
file we will use for the Thunderbird search option. If you installed this plugin yourself, you may find it in the [FF profile]/searchplugins/
directory. Otherwise, you can find it inside of the [FF app]/browser/omni.ja
archive. To find it, unzip the omni.ja
archive to a temporary location unzip omni.ja
(using the Info-ZIP utility; 7-Zip and other tools don't support the ZIP method Firefox uses). Then, in that temporary location, find the ddg.xml
file (find -iname ddg.xml
), perhaps at ./chrome/en-US/locale/browser/searchplugins/ddg.xml
, depending on your locale. Once you have located ddg.xml
, copy it to your [TB profile]/searchplugins/
directory.
Then, we want to use Firefox's search settings, but modify them slightly. Both Firefox and Thunderbird now compress their settings for performance, but this makes extracting and editing these settings much more difficult. To open a Mozilla compressed settings file, you can use the following code in your Browser Console (Ctrl+Shift+J
for me):
var { classes: Cc, interfaces: Ci, utils: Cu} = Components;
function decompressFile(oFilePath, nFilePath) {
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
return Task.spawn(function*() {
var jsonString = yield OS.File.read(oFilePath, {
compression: "lz4"
});
yield OS.File.writeAtomic(nFilePath, jsonString);
})
}
// Set up file chooser
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
var fu = Cu.import("resource://gre/modules/FileUtils.jsm").FileUtils
fp.init(window, "Open File", Ci.nsIFilePicker.modeOpen);
fp.appendFilter("Bookmarks/Session (.jsonlz4)", "*.jsonlz4");
fp.appendFilter("Search Engines (.mozlz4)", "*.mozlz4");
fp.appendFilter("Add-ons Files (.lz4)", "*.lz4");
// Call file chooser
fp.open((aResult) => {
if (aResult == Ci.nsIFilePicker.returnOK) {
if (fp.file.exists() && fp.file.isFile() && fp.file.isReadable()) {
var oldfile = fp.file.path;
var newfile = oldfile + ".json"; // Construct output file name
try {
decompressFile(oldfile, newfile);
console.log("Saved as: \"" + newfile + "\"");
if (confirm("Open JSON file in a Firefox tab?")) {
var uri = "file:///" + newfile.replace(/\\/g, "/");
window.open(uri, "_blank");
}
} catch (err) {
console.log(err);
}
}
}
});
With the above code, you want to open the [FF profile]/search.json.mozlz4
file and it will generate the file search.json.mozlz4.json
. Edit this JSON file, and assuming you have pretty-printed the contents, you want to edit the line for DuckDuckGo's _loadPath
variable, which will look something like the following:
"_loadPath":"jar:[app]/omni.ja!browser/ddg.xml",
You want to change this variable to point to the location within your Thunderbird profile where you copied the plugin file (and in this case, leave [profile]
as [profile]
; Thunderbird will interpret that as your [TB profile]
folder):
"_loadPath":"[profile]/searchplugins/ddg.xml",
At this point, ensure you have exited your Thunderbird instance and copy this file to [TB profile]/search.json
. Remove your existing [TB profile]/search.json.mozlz4
file, and then start Thunderbird again. Thunderbird should compress your file for you and now show DuckDuckGo as a selectable option in your Options > General > Default Search Engine
setting.
In summary, take following steps:
- Copy Firefox's
ddg.xml
file to your Thunderbird profile
- Decompress and edit your
search.json.mozlz4
settings file from Firefox to target the search plugin in Thunderbird, and use these new settings in your Thunderbird profile