Hi,
Here is the diff for the chromebar update:
diff --git a/config.def.h b/config.def.h
index 34265f6..ef33948 100644
--- a/config.def.h
+++ b/config.def.h
_AT__AT_ -121,6 +121,13 @@ static SiteSpecific certs[] = {
{ "://suckless\\.org/", "suckless.org.crt" },
};
+/* Search engines */
+static const char * defaultsearchengine = "
http://www.duckduckgo.com/?q=%s";
+static SearchEngine searchengines[] = {
+ { "dg", "
http://www.duckduckgo.com/?q=%s" },
+ { "leo", "
http://dict.leo.org/ende?search=%s" },
+ };
+
#define MODKEY GDK_CONTROL_MASK
/* hotkeys */
diff --git a/surf.c b/surf.c
index 2b54e3c..0ecbe4a 100644
--- a/surf.c
+++ b/surf.c
_AT__AT_ -128,6 +128,11 @@ typedef struct {
unsigned int stopevent;
} Button;
+typedef struct {
+char *token;
+char *uri;
+} SearchEngine;
+
typedef struct {
const char *uri;
Parameter config[ParameterLast];
_AT__AT_ -214,6 +219,7 @@ static void webprocessterminated(WebKitWebView *v,
Client *c);
static void closeview(WebKitWebView *v, Client *c);
static void destroywin(GtkWidget* w, Client *c);
+static gchar *parseuri(const gchar *uri);
/* Hotkeys */
static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
_AT__AT_ -559,7 +565,7 @@ loaduri(Client *c, const Arg *a)
url = g_strdup_printf("file://%s", path);
free(path);
} else {
-url = g_strdup_printf("
http://%s", uri);
+url = parseuri(uri);
}
if (apath != uri)
free(apath);
_AT__AT_ -1765,6 +1771,22 @@ destroywin(GtkWidget* w, Client *c)
gtk_main_quit();
}
+gchar *
+parseuri(const gchar *uri) {
+guint i;
+
+for (i = 0; i < LENGTH(searchengines); i++) {
+if (searchengines[i].token == NULL || searchengines[i].uri == NULL ||
+ *(uri + strlen(searchengines[i].token)) != ' ')
+continue;
+if (g_str_has_prefix(uri, searchengines[i].token))
+return g_strdup_printf(searchengines[i].uri,
+ uri + strlen(searchengines[i].token) + 1);
+}
+
+return g_strdup_printf(defaultsearchengine , uri);
+}
+
void
pasteuri(GtkClipboard *clipboard, const char *text, gpointer d)
{
Best,
Rhylx
Received on Thu Jun 04 2020 - 16:45:58 CEST