Modifying epiphany-search-provider to work with google-chrome [creating a google-chrome-search-provider for GNOME]

So I started out thinking I might be able to create a search provider for chrome until I saw /usr/libexec/epiphany-search-provider.

Since that does everything the search provider needs to do vis-a-vis interacting with the internet and dbus, I see no reason why the entirety cannot be used to call google-chrome at the end instead of epiphany, which i think is here:

launch_uri (const char *uri,
            guint       timestamp)
{
  g_autofree char *str = NULL;

  /* TODO: Handle the timestamp */
  str = g_strdup_printf ("google-chrome %s", uri);
  g_spawn_command_line_async (str, NULL);
}

I went to compile this but ran into an old dependency issue that will be a problem to address:
../meson.build:102:17: ERROR: Dependency "webkit2gtk-4.0" not found, tried pkgconfig and cmake

So, question one: is this the right tack to getting a working search provider for chrome sooner rather than later?

question two: how can I strip out the meson build file to get down to just what’s required for the search provider?

question three: how can i get that dependency or something else that will obviate the meson error?

  1. it appears that i require the webkit regardless as this includes the ephy-shell.h which #include <webkit2/webkit2.h> so it would be helpful but probably not practical.

In terms of " * Epiphany is distributed in the hope that it will be useful," it would be most helpful if it could actually bring web search to GNOME shell integration independent of browser choice.

1 Like

Epiphany is only going to show search results from your Epiphany history and bookmarks, though, so that doesn’t seem super useful. Surely you would want it to show results from Chrome instead?

If all you want is to display the “search the web” link and nothing else, then you can use the Epiphany search provider as a starting point, but you can probably delete most of the code, certainly including everything that depends on WebKit.

If you want to display history and bookmark search results comparable to what Epiphany does, you’ll probably want it to be part of the Chromium codebase.

I went to compile this but ran into an old dependency issue that will be a problem to address:
../meson.build:102:17: ERROR: Dependency "webkit2gtk-4.0" not found, tried pkgconfig and cmake

It looks like you’re trying to build a really old version of Epiphany. Just use a newer version?

Here’s some additional background about goals and what I’ve attempted so far. I have a thought I don’t want to get lost so I’m going to put it in a second reply.

It looks like you’re trying to build a really old version of Epiphany. Just use a newer version?
It looks like I was working on the source from an epiphany-3.36.4 tarball. I’ll give the cloned repo a try and see if that resolves the dependency issue.

Epiphany is only going to show search results from your Epiphany history and bookmarks, though, so that doesn’t seem super useful. Surely you would want it to show results from Chrome instead?

Until 30 minutes ago I was unaware that I’m presently getting search results from the dozen or so sites in my Web history (no bookmarks exist) so I was under the assumption that all I would be producing was:

If all you want is to display the “search the web” link and nothing else, then you can use the Epiphany search provider as a starting point, but you can probably delete most of the code, certainly including everything that depends on WebKit.

I don’t know C and making minimal changes to forked code with chatgpt has allowed me to gain functionality out of programs I would never have gotten otherwise. GNOME Web is my lightweight, i-have-to-use-a-browser-x-over-ssh choice, but Chrome’s my daily driver.

What’s happened is that when I hit start and begin typing and strike enter (because that’s what one does with a single result, I end up with Web opening instead of Chrome. I then need to close the opened GNOME Web window.

For starters that’s all I want to change…and it would have satisficed until I realized I might be able to have history and bookmarks from Chrome. I removed one of the links in the search-provider chain, (/usr/share/gnome-shell/search-providers/org.gnome.Epiphany.SearchProvider.ini) before I realized I can probably just turn it off in Settings > Search:

If you want to display history and bookmark search results comparable to what Epiphany does, you’ll probably want it to be part of the Chromium codebase.

Like I said, I would have ignorantly satisficed on just some web hits and launching my browser of choice and giving other GNOME users an easy way to have an integrated web-search-provider experience agnostic of end browser choice. Further, I like to kid myself that I’m proficient in BASH, but at best I’m puzzling through stuff with an iddiot savant that occasionally follows my instructions. Perhaps this will become a reality when some other necessary conditions are met:

  • I learn C, GNOME, etc.
  • AI programming gets appreciably better at digesting existing codebase
  • Someone who know how to do this decides they want a chrome-search-provider.

Until then, I’ve only the tools at hand so with that metaphorical hammer, I’m hitting this proverbial nail.

Is there an import feature in Web/Epiphany that would allow me to import from Chrome or another browser of choice (the Ubuntu-packaged Firefox coming immediately to mind)? If not, is that something that is planned? If Epiphany can at least import bookmarks, I would think that would be an easy and automatic improvement for those who use bookmarks.*

Anyway, again, thinking from the standpoint of efficiently using existing work I cannot produce for Chrome de novo, i.e., the ephy-search-provider.* code, it seems to me that if Epiphany can import the things it needs to search to provide history and bookmark suggestions in the integrated GNOME shell search paradigm, then maybe I’m looking at how to parse things instead of how to program a search provider, a task I am admittedly not equipped for.

*In truth, I don’t (I started using Hoarder, but so far I haven’t retrieved anything), I guess I mostly rely on Chrome’s automatic site suggestions when I start typing in the address box so that functionality would probably be the first thing I’d want to bring to a hypothetical chrome-search-provider.

../meson.build:101:17: ERROR: Dependency lookup for libadwaita-1 with method 'pkgconfig' failed: Invalid version, need 'libadwaita-1' ['>= 1.6.alpha'] found '1.5.1'.

This is build off of 1.6 alpha? I’m pulling from the Oracular repo and I can’t get that…

There’s some very-closely related info here that may be of use:

Epiphany does indeed support bookmarks import via Chrome (but not history import).

If you don’t want to build a newer libadwaita, I would start by deleting code that you don’t need. Honestly, it sounds like all you really want to do is display a single “Search the web for whatever” search result. Should be possible to delete almost everything. Building all of Epiphany just to display one search result would be overkill.

Thanks, I found the import bookmarks after my last post. I also saw something on Reddit that suggested Web’s history was a sqlite db:

Adding history to an existing sqlite db seems trivial, but I need to know which fields beyond a simple URL/title pair are required, which are used, and which are ignored for the search-provider function.

The Reddit post suggests getting the Chrome history in a usable fashion is not going to be a straight-forward export/import process, however, the ancillary programs around Chrome/Chromium are substantial compared to those around GNOME Web so I expect I’ll find something that lets me export Chrome history as a JSON or another useful data exchange format.

As a .csv: https://chromewebstore.google.com/detail/export-chrome-history/dihloblpkeiddiaojbagoecedbfpifdj?hl=en&pli=1
As a .json: https://chromewebstore.google.com/detail/export-historybookmarks-t/dcoegfodcnjofhjfbhegcgjgapeichlf?hl=en

Hm, well you might need to experiment here. The urls table is what the search provider is going to use. You’ll need to set id (which probably just has to be unique?), url, and title. The rest can be set to 0, except possibly the host row, which references an entry in the hosts table. There you’ll need to experiment. You can try setting it to 0 and hope it works.

thanks.

It appears the search provider is offering me suggestions from imported Chrome bookmarks. The search provider is launching a search in chrome, but was sending me to the sky at DuckDuckGo when I search ‘the sky’. I changed the default search engine in Web and now it opens in google. It seems pretty clear I could change the !ddg address to something else as necessary.

WRT to history, it certainly appears that I am seeing some old Web history in gnome-shell. I’m going to have to create some entries from chrome or whatever, but I see no reason to assume it won’t work…that said, there is an issue. In Web I searched for something I know won’t be in any history because I heard it on an audiobook recently and definately have never searched for ‘samuel colridge drugs’ [sic] before. I closed Web and opened it and whatnot, but that wasn’t coming up in the search-provider suggestions…though I just checked and they are now. It would be important to know what mechanism updates that because if I have chrome open the entire uptime of my machine [except when chrome crashes] then it will not show me recent results. If I need to start Web in order for it to do so, then I’ll need to do that as well.

Anyway, while there were some doubters on the libadwatia matrix server today, from what I can tell this can and will work. Jamming my Chrome history into epiphany’s history is a hack, but solves my problem.

I was reading this description on apt today: “Description: Intuitive GNOME web browser / Epiphany is a simple yet powerful GNOME web browser targeted at non-technical users,” and I’m not the target audience for GNOME Web. What I am is someone who has, since Ubuntu 10.04, been using GNOME and finding the classic/fallback/compiz/whatever to supplant e.g., Unity. I have found the search experience to be something that is very important to my use of the GUI and I’ve been delighted to extend it to finding characters and now using the it for the web. In fact, I would say that search is a central concept in the GNOME user experience. The search entry in the shell overview is the place to go for quick searches… wait, no, I read somewhere…

I really believe it is a shame that chrome users (who globally outnumber edge users by 5:1 and users of all browsers combined by 2:1) have been left out in the cold from that “central” concept.

You need a number for hosts in main.url or you get:
executeSQL: "FOREIGN KEY constraint failed (INSERT INTO \"main\".\"urls\"(\"id\",\"host\",\"url\",\"title\",\"sync_id\",\"last_visit_time\") VALUES (NULL,0,NULL,NULL,NULL,NULL);)"

I think restarting the search provider should be sufficient to pick up the new history database. It runs with a 1 minute inactivity timeout, so in theory just not using the gnome-shell overview for 1 minute should be sufficient. If not, then I’m not sure why it’s not noticing your new history.

Applications are expected to provide search providers; they are not provided by the desktop itself. E.g. Epiphany and Firefox both have search providers. Probably the only reason Chrome doesn’t have one is nobody has contributed it yet. For anyone who finds this thread in the future and decides to work on this, consider trying to reuse the code that populates results in the address bar dropdown. That is what Epiphany does.

Anyway, congrats on getting your hacky solution working.

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.