Add surf-searchengines
patch
This commit is contained in:
parent
e961680d86
commit
ccaad24f14
14
config.def.h
14
config.def.h
|
@ -9,6 +9,12 @@ static char *cookiefile = "~/.surf/cookies.txt";
|
||||||
static char *dldir = "~/dl/";
|
static char *dldir = "~/dl/";
|
||||||
static char *dlstatus = "~/.surf/dlstatus/";
|
static char *dlstatus = "~/.surf/dlstatus/";
|
||||||
|
|
||||||
|
static SearchEngine searchengines[] = {
|
||||||
|
{ "d ", "https://duckduckgo.com/?q=%s" },
|
||||||
|
{ "g ", "https://google.com/search?q=%s" },
|
||||||
|
{ "aw ", "https://wiki.archlinux.org/index.php?search=%s" },
|
||||||
|
};
|
||||||
|
|
||||||
/* Webkit default features */
|
/* Webkit default features */
|
||||||
/* Highest priority value will be used.
|
/* Highest priority value will be used.
|
||||||
* Default parameters are priority 0
|
* Default parameters are priority 0
|
||||||
|
@ -21,7 +27,7 @@ static Parameter defconfig[ParameterLast] = {
|
||||||
[AccessWebcam] = { { .i = 0 }, },
|
[AccessWebcam] = { { .i = 0 }, },
|
||||||
[Certificate] = { { .i = 0 }, },
|
[Certificate] = { { .i = 0 }, },
|
||||||
[CaretBrowsing] = { { .i = 0 }, },
|
[CaretBrowsing] = { { .i = 0 }, },
|
||||||
[CookiePolicies] = { { .v = "@Aa" }, },
|
[CookiePolicies] = { { .v = "A" }, },
|
||||||
[DefaultCharset] = { { .v = "UTF-8" }, },
|
[DefaultCharset] = { { .v = "UTF-8" }, },
|
||||||
[DiskCache] = { { .i = 1 }, },
|
[DiskCache] = { { .i = 1 }, },
|
||||||
[DNSPrefetch] = { { .i = 0 }, },
|
[DNSPrefetch] = { { .i = 0 }, },
|
||||||
|
@ -101,11 +107,6 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Quick searching. */
|
|
||||||
#define QSEARCH { \
|
|
||||||
.v = (char *[]){"/bin/sh", "-c", "surf_qsearch $0 $1", winid, NULL } \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* styles */
|
/* styles */
|
||||||
/*
|
/*
|
||||||
* The iteration will stop at the first match, beginning at the beginning of
|
* The iteration will stop at the first match, beginning at the beginning of
|
||||||
|
@ -183,7 +184,6 @@ static Key keys[] = {
|
||||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } },
|
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } },
|
||||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_t, toggle, { .i = StrictTLS } },
|
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_t, toggle, { .i = StrictTLS } },
|
||||||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } },
|
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } },
|
||||||
{ MODKEY, GDK_KEY_s, spawn, QSEARCH },
|
|
||||||
/* download-console */
|
/* download-console */
|
||||||
{ MODKEY, GDK_KEY_d, spawndls, { 0 } },
|
{ MODKEY, GDK_KEY_d, spawndls, { 0 } },
|
||||||
};
|
};
|
||||||
|
|
6
config.h
6
config.h
|
@ -9,6 +9,12 @@ static char *cookiefile = "~/.surf/cookies.txt";
|
||||||
static char *dldir = "~/dl/";
|
static char *dldir = "~/dl/";
|
||||||
static char *dlstatus = "~/.surf/dlstatus/";
|
static char *dlstatus = "~/.surf/dlstatus/";
|
||||||
|
|
||||||
|
static SearchEngine searchengines[] = {
|
||||||
|
{ "d ", "https://duckduckgo.com/?q=%s" },
|
||||||
|
{ "g ", "https://google.com/search?q=%s" },
|
||||||
|
{ "aw ", "https://wiki.archlinux.org/index.php?search=%s" },
|
||||||
|
};
|
||||||
|
|
||||||
/* Webkit default features */
|
/* Webkit default features */
|
||||||
/* Highest priority value will be used.
|
/* Highest priority value will be used.
|
||||||
* Default parameters are priority 0
|
* Default parameters are priority 0
|
||||||
|
|
22
surf.c
22
surf.c
|
@ -129,6 +129,11 @@ typedef struct {
|
||||||
unsigned int stopevent;
|
unsigned int stopevent;
|
||||||
} Button;
|
} Button;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *token;
|
||||||
|
char *uri;
|
||||||
|
} SearchEngine;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *uri;
|
const char *uri;
|
||||||
Parameter config[ParameterLast];
|
Parameter config[ParameterLast];
|
||||||
|
@ -216,6 +221,7 @@ static void webprocessterminated(WebKitWebView *v,
|
||||||
Client *c);
|
Client *c);
|
||||||
static void closeview(WebKitWebView *v, Client *c);
|
static void closeview(WebKitWebView *v, Client *c);
|
||||||
static void destroywin(GtkWidget* w, Client *c);
|
static void destroywin(GtkWidget* w, Client *c);
|
||||||
|
static gchar *parseuri(const gchar *uri);
|
||||||
|
|
||||||
/* Hotkeys */
|
/* Hotkeys */
|
||||||
static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
|
static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
|
||||||
|
@ -589,7 +595,7 @@ loaduri(Client *c, const Arg *a)
|
||||||
url = g_strdup_printf("file://%s", path);
|
url = g_strdup_printf("file://%s", path);
|
||||||
free(path);
|
free(path);
|
||||||
} else {
|
} else {
|
||||||
url = g_strdup_printf("http://%s", uri);
|
url = parseuri(uri);
|
||||||
}
|
}
|
||||||
if (apath != uri)
|
if (apath != uri)
|
||||||
free(apath);
|
free(apath);
|
||||||
|
@ -1769,6 +1775,20 @@ destroywin(GtkWidget* w, Client *c)
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
parseuri(const gchar *uri)
|
||||||
|
{
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
for (i = 0; i < LENGTH(searchengines); i++) {
|
||||||
|
if (g_str_has_prefix(uri, searchengines[i].token))
|
||||||
|
return g_strdup_printf(searchengines[i].uri,
|
||||||
|
uri + strlen(searchengines[i].token));
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_strdup_printf("http://%s", uri);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pasteuri(GtkClipboard *clipboard, const char *text, gpointer d)
|
pasteuri(GtkClipboard *clipboard, const char *text, gpointer d)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue