Sample Search Provider provides an outline and example of a GNOME Shell Extension to you to integrate custom search providers in GNOME Shell (i.e. the default overlay in GNOME based linux systems).
This project can serve as a tutorial as well as a base project for your custom search providers.
- Recoll Search Provider integrates the recoll full-text search results into GNOME Shell
To adapt the project for your needs the following steps are necessary:
This code can also be used to built your own search provider extension for other services:
- edit "metadata.json": change the relevant information. Note that your folder name must be the same as the
uuid
in your metadata.json - edit "extension.js": change the constants under
/** APP CONFIG **/
as needed:
APP_NAME
: name that is displayed for your app in the GNOME ShellICON_NAME
: filename (without filetype extension) of the icon in the "icons" subfolder of your extensionSEARCH_TERMS_FILTER
: [(searchTerms: string[]) => boolean
] function to return true whenever your extension should provide search results based on the search terms entered. (Example:SEARCH_TERMS_FILTER = (terms => { return (terms[0].substring(0, 2) === 'd:'
)SEARCH_CLIENT
: Import of a script that provides a search api. Must implement a factory methodgetSearchClient()
.
- Update the settings schema in xml format in the subfolder "schemas"
- run
glib-compile-schemas ./schemas
to compile a binary version of your settings
The "search client" is your code actually managing the retrieval of search results independent of GNOME Shell specifics. You can base your implementation on one of the existing samples getting results from an online source or from a simple commandline (console) output.
- Copy "search_client_sample_from_web.js" or "search_client_sample_from_console.js" to get started and adapt it to conduct the type of search you want.
- Functions prefixed with
_
(e.g._buildQueryUrl()
) are considered private, feel free to change their names or remove them. - If you want to use your "search client" implementation without changing the "extension.js" code, your "search client"
needs to implement at least
function getSearchClient()
to return an object that has the methodsget(searchterm, callback)
anddestroy()
. For details see the commented "search_client_sample.js".
- To see changes in the code you have to restart GNOME Shell - either press
Alt
+F2
and typer
or rungnome-shell --replace
in a terminal. - Enable your extension through GNOME Tweak Tool.
- Looking Glass helps with debugging and shows the errors in your extension. Simply press
Alt
+F2
and typelg
in the command prompt.
- Basics of creating an Extension (gnome.org wiki)
- Using GSettings, the settings schema xml file
- Gnome shell extensions: Getting started writing your own, a fairly good introductory blog post
- http://smasue.github.io/gnome-shell-tw, another, more recent tutorial post