Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have added additional search providers (e.g., AskUbuntu, Wolfram, YouTube) in the /usr/share/gnome-shell/search_providers directory. These work great. However, the order in which they appear on the Activities Overview is not logical.

Is it possible to change the order in which search providers are displayed?

Bonus: How do I make one the default?

share|improve this question
add comment

4 Answers

up vote 8 down vote accepted

11.10

There is a key that is referred to in the gnome-shell search code that allows you to specify which search providers should not be displayed...

By changing the logic you can change that to be a search order list - for example

gsettings set org.gnome.shell disabled-open-search-providers "['duckduckgo.xml', 'google.xml', 'wikipedia.xml']"

enter image description here

gsettings set org.gnome.shell disabled-open-search-providers "['wikipedia.xml', 'duckduckgo.xml', 'google.xml']"

enter image description here

how to

First make a backup copy of the search script:

sudo cp /usr/share/gnome-shell/js/ui/search.js /usr/share/gnome-shell/js/ui/search.js.backup

Now edit the search script:

gksudo gedit /usr/share/gnome-shell/js/ui/search.js

Look for the function containing the following code (it probably starts on line 325):

 _refresh: function() {
        this._providers = []; 
        let names = global.settings.get_strv(DISABLED_OPEN_SEARCH_PROVIDERS_KEY);
        let file = Gio.file_new_for_path(global.datadir + '/search_providers');
        FileUtils.listDirAsync(file, Lang.bind(this, function(files) {
            for (let i = 0; i < files.length; i++) {
                let enabled = true; 
                let name = files[i].get_name();
                for (let k = 0; k < names.length; k++)
                    if (names[k] == name)
                        enabled = false;
                if (enabled)
                    this._addProvider(name);
            }           
        }));    
    }

Change this function to be:

_refresh: function() {
        this._providers = [];
        let names = global.settings.get_strv(DISABLED_OPEN_SEARCH_PROVIDERS_KEY);
        let file = Gio.file_new_for_path(global.datadir + '/search_providers');
        FileUtils.listDirAsync(file, Lang.bind(this, function(files) {
            for (let i = 0; i < names.length; i++) {
                for (let k = 0; k < files.length; k++) 
                    if (names[i] == files[k].get_name())
                        this._addProvider(names[i])
            }               
        }));    
    }

Press Alt+F2, type 'r' and press enter. This should restart Gnome-shell). Alternatively, logout and login.

credit


Linked Questions:

  1. Is it possible to customise the search engine buttons in GNOME Shell?
  2. Is it possible to remove or replace Google search in GNOME Shell's dash?
share|improve this answer
add comment

To preserve the meaning of the gsettings variable, another possibility would be to modify search.js to order search providers files by name:

    FileUtils.listDirAsync(file, Lang.bind(this, function(files) {
        files.sort (function (first, second) {
            return first.get_name () <= second.get_name ()? -1: 1
        });

Then you would rename the files in /usr/share/gnome-shell/search_providers like

01_google.xml
02_wikipedia.xml
... 

Carlo.

share|improve this answer
add comment

I found that it arranges them in time order. The search provider which was added latest is first. So if you want to bring Google first just move it somewhere, refresh (Alt+F2 and R), recopy it to the folder and refresh again.

share|improve this answer
add comment

Alternative method: Gnome Shell seems to favour the search provider tied to the most recently edited .xml file; to create a custom arrangement, it will be enough to open the files, save them, and restart the shell. If your desired order is, for example: Google, Wikipedia, DuckDuckGo - then DuckDuckGo should be the one you save first, followed by Wikipedia and then Google.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.