]> git.armaanb.net Git - chorizo.git/commitdiff
Add initial changes
authorArmaan Bhojwani <me@armaanb.net>
Mon, 24 May 2021 18:18:29 +0000 (14:18 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Sun, 6 Jun 2021 13:48:58 +0000 (09:48 -0400)
Makefile
browser.c
man1/lariza-usage.1 [new file with mode: 0644]
man1/lariza.1
man1/lariza.usage.1 [deleted file]
user-scripts/privacy-redirect.js [new file with mode: 0644]

index f05e44880f823cd2c7acc6354511ffb6fb643a85..90fcf6fa37770f57570c7af71e12322032082980 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,53 +1,50 @@
 CFLAGS += -Wall -Wextra -Wno-unused-parameter -O3
-__NAME__ = lariza
-__NAME_UPPERCASE__ = LARIZA
-
-INSTALL = install
-INSTALL_PROGRAM = $(INSTALL)
-INSTALL_DATA = $(INSTALL) -m 644
 
 prefix = /usr/local
 exec_prefix = $(prefix)
 bindir = $(exec_prefix)/bin
 libdir = $(exec_prefix)/lib
 datarootdir = $(prefix)/share
-mandir = $(datarootdir)/man
-man1dir = $(mandir)/man1
+mandir = $(datarootdir)/man/man1
 datadir = $(prefix)/share
 
 
-.PHONY: all clean install installdirs
+.PHONY: all clean uninstall install
 
-all: $(__NAME__) we_adblock.so
 
-$(__NAME__): browser.c
+lariza: browser.c
        $(CC) $(CFLAGS) $(LDFLAGS) \
-               -D__NAME__=\"$(__NAME__)\" \
-               -D__NAME_UPPERCASE__=\"$(__NAME_UPPERCASE__)\" \
+               -D__NAME__=\"lariza\" \
+               -D__NAME_UPPERCASE__=\"LARIZA\" \
                -o $@ $< \
                `pkg-config --cflags --libs gtk+-3.0 glib-2.0 webkit2gtk-4.0`
 
 we_adblock.so: we_adblock.c
        $(CC) $(CFLAGS) $(LDFLAGS) \
-               -D__NAME__=\"$(__NAME__)\" \
-               -D__NAME_UPPERCASE__=\"$(__NAME_UPPERCASE__)\" \
+               -D__NAME__=\"lariza\" \
+               -D__NAME_UPPERCASE__=\"LARIZA\" \
                -shared -o $@ -fPIC $< \
                `pkg-config --cflags --libs glib-2.0 webkit2gtk-4.0`
 
-install: all installdirs
-       $(INSTALL_PROGRAM) $(__NAME__) $(DESTDIR)$(bindir)/$(__NAME__)
-       $(INSTALL_DATA) man1/$(__NAME__).1 $(DESTDIR)$(man1dir)/$(__NAME__).1
-       $(INSTALL_DATA) man1/$(__NAME__).usage.1 \
-               $(DESTDIR)$(man1dir)/$(__NAME__).usage.1
-       $(INSTALL_PROGRAM) we_adblock.so \
-               $(DESTDIR)$(libdir)/$(__NAME__)/web_extensions/we_adblock.so
-       $(INSTALL_DATA) user-scripts/hints.js \
-               $(DESTDIR)$(datadir)/$(__NAME__)/user-scripts/hints.js
-
-installdirs:
-       mkdir -p $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir) \
-               $(DESTDIR)$(libdir)/$(__NAME__)/web_extensions \
-               $(DESTDIR)$(datadir)/$(__NAME__)/user-scripts
+install: all
+       mkdir -p $(DESTDIR)$(bindir) \
+               $(DESTDIR)$(man1dir) \
+               $(DESTDIR)$(libdir)/lariza/web_extensions \
+               $(DESTDIR)$(datadir)/lariza/user-scripts
+
+       cp lariza $(DESTDIR)$(bindir)/lariza
+       cp we_adblock.so $(DESTDIR)$(libdir)/lariza/web_extensions/we_adblock.so
+       cp man1/* $(DESTDIR)$(man1dir)/
+       cp -r user-scripts/* $(DESTDIR)$(datadir)/lariza/user-scripts/
+
+uninstall:
+       rm -rf $(DESTDIR)$(bindir)/lariza \
+               $(DESTDIR)$(libdir)/lariza \
+               $(DESTDIR)$(man1dir)/lariza* \
+               $(DESTDIR)$(datadir)/lariza
+
+reinstall: uninstall install
+
 
 clean:
-       rm -f $(__NAME__) we_adblock.so
+       rm -f lariza we_adblock.so
index ebab7fb82e66a265ef6fcc3e294ad4beb1d2a5cc..66fc699453bc9b055aa8fdb1a6218e8395036ca1 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -16,9 +16,9 @@
 
 void client_destroy(GtkWidget *, gpointer);
 WebKitWebView *client_new(const gchar *, WebKitWebView *, gboolean,
-                          gboolean);
+                                                                                                       gboolean);
 WebKitWebView *client_new_request(WebKitWebView *, WebKitNavigationAction *,
-                                  gpointer);
+                                                                                                                                       gpointer);
 void cooperation_setup(void);
 void changed_download_progress(GObject *, GParamSpec *, gpointer);
 void changed_load_progress(GObject *, GParamSpec *, gpointer);
@@ -27,7 +27,7 @@ void changed_title(GObject *, GParamSpec *, gpointer);
 void changed_uri(GObject *, GParamSpec *, gpointer);
 gboolean crashed_web_view(WebKitWebView *, gpointer);
 gboolean decide_policy(WebKitWebView *, WebKitPolicyDecision *,
-                       WebKitPolicyDecisionType, gpointer);
+                                                                                        WebKitPolicyDecisionType, gpointer);
 gboolean download_handle(WebKitDownload *, gchar *, gpointer);
 void download_handle_start(WebKitWebView *, WebKitDownload *, gpointer);
 void downloadmanager_cancel(GtkToolButton *, gpointer);
@@ -54,31 +54,30 @@ void search(gpointer, gint);
 void show_web_view(WebKitWebView *, gpointer);
 void trust_user_certs(WebKitWebContext *);
 
-
 struct Client
 {
-    gchar *external_handler_uri;
-    gchar *hover_uri;
-    gchar *feed_html;
-    GtkWidget *location;
-    GtkWidget *tabicon;
-    GtkWidget *tablabel;
-    GtkWidget *vbox;
-    GtkWidget *web_view;
-    gboolean focus_new_tab;
+       gchar *external_handler_uri;
+       gchar *hover_uri;
+       gchar *feed_html;
+       GtkWidget *location;
+       GtkWidget *tabicon;
+       GtkWidget *tablabel;
+       GtkWidget *vbox;
+       GtkWidget *web_view;
+       gboolean focus_new_tab;
 };
 
 struct MainWindow
 {
-    GtkWidget *win;
-    GtkWidget *notebook;
+       GtkWidget *win;
+       GtkWidget *notebook;
 } mw;
 
 struct DownloadManager
 {
-    GtkWidget *scroll;
-    GtkWidget *toolbar;
-    GtkWidget *win;
+       GtkWidget *scroll;
+       GtkWidget *toolbar;
+       GtkWidget *win;
 } dm;
 
 
@@ -102,1207 +101,1203 @@ gchar *user_agent = NULL;
 void
 client_destroy(GtkWidget *widget, gpointer data)
 {
-    struct Client *c = (struct Client *)data;
-    gint idx;
+       struct Client *c = (struct Client *)data;
+       gint idx;
 
-    g_signal_handlers_disconnect_by_func(G_OBJECT(c->web_view),
-                                         changed_load_progress, c);
+       g_signal_handlers_disconnect_by_func(G_OBJECT(c->web_view),
+                                                                                                                                                        changed_load_progress, c);
 
-    idx = gtk_notebook_page_num(GTK_NOTEBOOK(mw.notebook), c->vbox);
-    if (idx == -1)
-        fprintf(stderr, __NAME__": Tab index was -1, bamboozled\n");
-    else
-        gtk_notebook_remove_page(GTK_NOTEBOOK(mw.notebook), idx);
+       idx = gtk_notebook_page_num(GTK_NOTEBOOK(mw.notebook), c->vbox);
+       if (idx == -1)
+               fprintf(stderr, __NAME__": Tab index was -1, bamboozled\n");
+       else
+               gtk_notebook_remove_page(GTK_NOTEBOOK(mw.notebook), idx);
 
-    free(c);
-    clients--;
+       free(c);
+       clients--;
 
-    quit_if_nothing_active();
+       quit_if_nothing_active();
 }
 
 WebKitWebView *
 client_new(const gchar *uri, WebKitWebView *related_wv, gboolean show,
-           gboolean focus_tab)
+                                        gboolean focus_tab)
 {
-    struct Client *c;
-    gchar *f;
-    GtkWidget *evbox, *tabbox;
-
-    if (uri != NULL && cooperative_instances && !cooperative_alone)
-    {
-        f = ensure_uri_scheme(uri);
-        write(cooperative_pipe_fp, f, strlen(f));
-        write(cooperative_pipe_fp, "\n", 1);
-        g_free(f);
-        return NULL;
-    }
-
-    c = calloc(1, sizeof(struct Client));
-    if (!c)
-    {
-        fprintf(stderr, __NAME__": fatal: calloc failed\n");
-        exit(EXIT_FAILURE);
-    }
-
-    c->focus_new_tab = focus_tab;
-
-    if (related_wv == NULL)
-        c->web_view = webkit_web_view_new();
-    else
-        c->web_view = webkit_web_view_new_with_related_view(related_wv);
-
-    webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(c->web_view), global_zoom);
-    g_signal_connect(G_OBJECT(c->web_view), "notify::favicon",
-                     G_CALLBACK(changed_favicon), c);
-    g_signal_connect(G_OBJECT(c->web_view), "notify::title",
-                     G_CALLBACK(changed_title), c);
-    g_signal_connect(G_OBJECT(c->web_view), "notify::uri",
-                     G_CALLBACK(changed_uri), c);
-    g_signal_connect(G_OBJECT(c->web_view), "notify::estimated-load-progress",
-                     G_CALLBACK(changed_load_progress), c);
-    g_signal_connect(G_OBJECT(c->web_view), "create",
-                     G_CALLBACK(client_new_request), NULL);
-    g_signal_connect(G_OBJECT(c->web_view), "close",
-                     G_CALLBACK(client_destroy), c);
-    g_signal_connect(G_OBJECT(c->web_view), "decide-policy",
-                     G_CALLBACK(decide_policy), NULL);
-    g_signal_connect(G_OBJECT(c->web_view), "key-press-event",
-                     G_CALLBACK(key_web_view), c);
-    g_signal_connect(G_OBJECT(c->web_view), "button-release-event",
-                     G_CALLBACK(key_web_view), c);
-    g_signal_connect(G_OBJECT(c->web_view), "scroll-event",
-                     G_CALLBACK(key_web_view), c);
-    g_signal_connect(G_OBJECT(c->web_view), "mouse-target-changed",
-                     G_CALLBACK(hover_web_view), c);
-    g_signal_connect(G_OBJECT(c->web_view), "web-process-crashed",
-                     G_CALLBACK(crashed_web_view), c);
-
-    if (user_agent != NULL)
-        g_object_set(G_OBJECT(webkit_web_view_get_settings(WEBKIT_WEB_VIEW(c->web_view))),
-                     "user-agent", user_agent, NULL);
-
-    if (enable_console_to_stdout)
-        webkit_settings_set_enable_write_console_messages_to_stdout(webkit_web_view_get_settings(WEBKIT_WEB_VIEW(c->web_view)), TRUE);
-
-    webkit_settings_set_enable_developer_extras(webkit_web_view_get_settings(WEBKIT_WEB_VIEW(c->web_view)), TRUE);
-
-    c->location = gtk_entry_new();
-    g_signal_connect(G_OBJECT(c->location), "key-press-event",
-                     G_CALLBACK(key_location), c);
-    g_signal_connect(G_OBJECT(c->location), "icon-release",
-                     G_CALLBACK(icon_location), c);
-    /* XXX This is a workaround. Setting this to NULL (which is done in
-     * grab_feeds_finished() if no feed has been detected) adds a little
-     * padding left of the text. Not sure why. The point of this call
-     * right here is to have that padding right from the start. This
-     * avoids a graphical artifact. */
-    gtk_entry_set_icon_from_icon_name(GTK_ENTRY(c->location),
-                                      GTK_ENTRY_ICON_PRIMARY,
-                                      NULL);
-
-    c->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
-    gtk_box_pack_start(GTK_BOX(c->vbox), c->location, FALSE, FALSE, 0);
-    gtk_box_pack_start(GTK_BOX(c->vbox), c->web_view, TRUE, TRUE, 0);
-    gtk_container_set_focus_child(GTK_CONTAINER(c->vbox), c->web_view);
-
-    c->tabicon = gtk_image_new_from_icon_name("text-html", GTK_ICON_SIZE_SMALL_TOOLBAR);
-
-    c->tablabel = gtk_label_new(__NAME__);
-    gtk_label_set_ellipsize(GTK_LABEL(c->tablabel), PANGO_ELLIPSIZE_END);
-    gtk_label_set_width_chars(GTK_LABEL(c->tablabel), tab_width_chars);
-    gtk_widget_set_has_tooltip(c->tablabel, TRUE);
-
-    /* XXX I don't own a HiDPI screen, so I don't know if scale_factor
-     * does the right thing. */
-    tabbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,
-                         5 * gtk_widget_get_scale_factor(mw.win));
-    gtk_box_pack_start(GTK_BOX(tabbox), c->tabicon, FALSE, FALSE, 0);
-    gtk_box_pack_start(GTK_BOX(tabbox), c->tablabel, TRUE, TRUE, 0);
-
-    evbox = gtk_event_box_new();
-    gtk_container_add(GTK_CONTAINER(evbox), tabbox);
-    g_signal_connect(G_OBJECT(evbox), "button-release-event",
-                     G_CALLBACK(key_tablabel), c);
-
-    gtk_widget_add_events(evbox, GDK_SCROLL_MASK);
-    g_signal_connect(G_OBJECT(evbox), "scroll-event",
-                     G_CALLBACK(key_tablabel), c);
-
-    /* For easy access, store a reference to our label. */
-    g_object_set_data(G_OBJECT(evbox), "lariza-tab-label", c->tablabel);
-
-    /* This only shows the event box and the label inside, nothing else.
-     * Needed because the evbox/label is "internal" to the notebook and
-     * not part of the normal "widget tree" (IIUC). */
-    gtk_widget_show_all(evbox);
-
-    gtk_notebook_insert_page(GTK_NOTEBOOK(mw.notebook), c->vbox, evbox,
-                             gtk_notebook_get_current_page(GTK_NOTEBOOK(mw.notebook)) + 1);
-    gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(mw.notebook), c->vbox, TRUE);
-
-    if (show)
-        show_web_view(NULL, c);
-    else
-        g_signal_connect(G_OBJECT(c->web_view), "ready-to-show",
-                         G_CALLBACK(show_web_view), c);
-
-    if (uri != NULL)
-    {
-        f = ensure_uri_scheme(uri);
-        webkit_web_view_load_uri(WEBKIT_WEB_VIEW(c->web_view), f);
-        g_free(f);
-    }
-
-    clients++;
-
-    return WEBKIT_WEB_VIEW(c->web_view);
+       struct Client *c;
+       gchar *f;
+       GtkWidget *evbox, *tabbox;
+
+       if (uri != NULL && cooperative_instances && !cooperative_alone) {
+               f = ensure_uri_scheme(uri);
+               write(cooperative_pipe_fp, f, strlen(f));
+               write(cooperative_pipe_fp, "\n", 1);
+               g_free(f);
+               return NULL;
+       }
+
+       c = calloc(1, sizeof(struct Client));
+       if (!c) {
+               fprintf(stderr, __NAME__": fatal: calloc failed\n");
+               exit(EXIT_FAILURE);
+       }
+
+       c->focus_new_tab = focus_tab;
+
+       if (related_wv == NULL)
+               c->web_view = webkit_web_view_new();
+       else
+               c->web_view = webkit_web_view_new_with_related_view(related_wv);
+
+       webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(c->web_view), global_zoom);
+       g_signal_connect(G_OBJECT(c->web_view), "notify::favicon",
+                                                                        G_CALLBACK(changed_favicon), c);
+       g_signal_connect(G_OBJECT(c->web_view), "notify::title",
+                                                                        G_CALLBACK(changed_title), c);
+       g_signal_connect(G_OBJECT(c->web_view), "notify::uri",
+                                                                        G_CALLBACK(changed_uri), c);
+       g_signal_connect(G_OBJECT(c->web_view), "notify::estimated-load-progress",
+                                                                        G_CALLBACK(changed_load_progress), c);
+       g_signal_connect(G_OBJECT(c->web_view), "create",
+                                                                        G_CALLBACK(client_new_request), NULL);
+       g_signal_connect(G_OBJECT(c->web_view), "close",
+                                                                        G_CALLBACK(client_destroy), c);
+       g_signal_connect(G_OBJECT(c->web_view), "decide-policy",
+                                                                        G_CALLBACK(decide_policy), NULL);
+       g_signal_connect(G_OBJECT(c->web_view), "key-press-event",
+                                                                        G_CALLBACK(key_web_view), c);
+       g_signal_connect(G_OBJECT(c->web_view), "button-release-event",
+                                                                        G_CALLBACK(key_web_view), c);
+       g_signal_connect(G_OBJECT(c->web_view), "scroll-event",
+                                                                        G_CALLBACK(key_web_view), c);
+       g_signal_connect(G_OBJECT(c->web_view), "mouse-target-changed",
+                                                                        G_CALLBACK(hover_web_view), c);
+       g_signal_connect(G_OBJECT(c->web_view), "web-process-crashed",
+                                                                        G_CALLBACK(crashed_web_view), c);
+
+       if (user_agent != NULL)
+               g_object_set(G_OBJECT(webkit_web_view_get_settings(WEBKIT_WEB_VIEW(c->web_view))),
+                                                                "user-agent", user_agent, NULL);
+
+       if (enable_console_to_stdout)
+               webkit_settings_set_enable_write_console_messages_to_stdout(webkit_web_view_get_settings(WEBKIT_WEB_VIEW(c->web_view)), TRUE);
+
+       webkit_settings_set_enable_developer_extras(webkit_web_view_get_settings(WEBKIT_WEB_VIEW(c->web_view)), TRUE);
+
+       c->location = gtk_entry_new();
+       g_signal_connect(G_OBJECT(c->location), "key-press-event",
+                                                                        G_CALLBACK(key_location), c);
+       g_signal_connect(G_OBJECT(c->location), "icon-release",
+                                                                        G_CALLBACK(icon_location), c);
+       /* XXX This is a workaround. Setting this to NULL (which is done in
+        * grab_feeds_finished() if no feed has been detected) adds a little
+        * padding left of the text. Not sure why. The point of this call
+        * right here is to have that padding right from the start. This
+        * avoids a graphical artifact. */
+       gtk_entry_set_icon_from_icon_name(GTK_ENTRY(c->location),
+                                                                                                                                               GTK_ENTRY_ICON_PRIMARY,
+                                                                                                                                               NULL);
+
+       c->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+       gtk_box_pack_start(GTK_BOX(c->vbox), c->location, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(c->vbox), c->web_view, TRUE, TRUE, 0);
+       gtk_container_set_focus_child(GTK_CONTAINER(c->vbox), c->web_view);
+
+       c->tabicon = gtk_image_new_from_icon_name("text-html", GTK_ICON_SIZE_SMALL_TOOLBAR);
+
+       c->tablabel = gtk_label_new(__NAME__);
+       gtk_label_set_ellipsize(GTK_LABEL(c->tablabel), PANGO_ELLIPSIZE_END);
+       gtk_label_set_width_chars(GTK_LABEL(c->tablabel), tab_width_chars);
+       gtk_widget_set_has_tooltip(c->tablabel, TRUE);
+
+       /* XXX I don't own a HiDPI screen, so I don't know if scale_factor
+        * does the right thing. */
+       tabbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,
+                                                                                        5 * gtk_widget_get_scale_factor(mw.win));
+       gtk_box_pack_start(GTK_BOX(tabbox), c->tabicon, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(tabbox), c->tablabel, TRUE, TRUE, 0);
+
+       evbox = gtk_event_box_new();
+       gtk_container_add(GTK_CONTAINER(evbox), tabbox);
+       g_signal_connect(G_OBJECT(evbox), "button-release-event",
+                                                                        G_CALLBACK(key_tablabel), c);
+
+       gtk_widget_add_events(evbox, GDK_SCROLL_MASK);
+       g_signal_connect(G_OBJECT(evbox), "scroll-event",
+                                                                        G_CALLBACK(key_tablabel), c);
+
+       /* For easy access, store a reference to our label. */
+       g_object_set_data(G_OBJECT(evbox), "lariza-tab-label", c->tablabel);
+
+       /* This only shows the event box and the label inside, nothing else.
+        * Needed because the evbox/label is "internal" to the notebook and
+        * not part of the normal "widget tree" (IIUC). */
+       gtk_widget_show_all(evbox);
+
+       gtk_notebook_insert_page(GTK_NOTEBOOK(mw.notebook), c->vbox, evbox,
+                                                                                                        gtk_notebook_get_current_page(GTK_NOTEBOOK(mw.notebook)) + 1);
+       gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(mw.notebook), c->vbox, TRUE);
+
+       if (show)
+               show_web_view(NULL, c);
+       else
+               g_signal_connect(G_OBJECT(c->web_view), "ready-to-show",
+                                                                                G_CALLBACK(show_web_view), c);
+
+       if (uri != NULL) {
+               f = ensure_uri_scheme(uri);
+               webkit_web_view_load_uri(WEBKIT_WEB_VIEW(c->web_view), f);
+               g_free(f);
+       }
+
+       clients++;
+
+       return WEBKIT_WEB_VIEW(c->web_view);
 }
 
 WebKitWebView *
 client_new_request(WebKitWebView *web_view,
-                   WebKitNavigationAction *navigation_action, gpointer data)
+                                                                        WebKitNavigationAction *navigation_action, gpointer data)
 {
-    return client_new(NULL, web_view, FALSE, FALSE);
+       return client_new(NULL, web_view, FALSE, FALSE);
 }
 
 void
 cooperation_setup(void)
 {
-    GIOChannel *towatch;
-    gchar *fifofilename, *fifopath;
-
-    fifofilename = g_strdup_printf("%s-%s", __NAME__".fifo", fifo_suffix);
-    fifopath = g_build_filename(g_get_user_runtime_dir(), fifofilename, NULL);
-    g_free(fifofilename);
-
-    if (!g_file_test(fifopath, G_FILE_TEST_EXISTS))
-        mkfifo(fifopath, 0600);
-
-    cooperative_pipe_fp = open(fifopath, O_WRONLY | O_NONBLOCK);
-    if (!cooperative_pipe_fp)
-    {
-        fprintf(stderr, __NAME__": Can't open FIFO at all.\n");
-    }
-    else
-    {
-        if (write(cooperative_pipe_fp, "", 0) == -1)
-        {
-            /* Could not do an empty write to the FIFO which means there's
-             * no one listening. */
-            close(cooperative_pipe_fp);
-            towatch = g_io_channel_new_file(fifopath, "r+", NULL);
-            g_io_add_watch(towatch, G_IO_IN, (GIOFunc)remote_msg, NULL);
-        }
-        else
-            cooperative_alone = FALSE;
-    }
-
-    g_free(fifopath);
+       GIOChannel *towatch;
+       gchar *fifofilename, *fifopath;
+
+       fifofilename = g_strdup_printf("%s-%s", __NAME__".fifo", fifo_suffix);
+       fifopath = g_build_filename(g_get_user_runtime_dir(), fifofilename, NULL);
+       g_free(fifofilename);
+
+       if (!g_file_test(fifopath, G_FILE_TEST_EXISTS))
+               mkfifo(fifopath, 0600);
+
+       cooperative_pipe_fp = open(fifopath, O_WRONLY | O_NONBLOCK);
+       if (!cooperative_pipe_fp) {
+               fprintf(stderr, __NAME__": Can't open FIFO at all.\n");
+       } else {
+               if (write(cooperative_pipe_fp, "", 0) == -1) {
+                       /* Could not do an empty write to the FIFO which means there's
+                        * no one listening. */
+                       close(cooperative_pipe_fp);
+                       towatch = g_io_channel_new_file(fifopath, "r+", NULL);
+                       g_io_add_watch(towatch, G_IO_IN, (GIOFunc)remote_msg, NULL);
+               } else {
+                       cooperative_alone = FALSE;
+               }
+       }
+
+       g_free(fifopath);
 }
 
 void
 changed_download_progress(GObject *obj, GParamSpec *pspec, gpointer data)
 {
-    WebKitDownload *download = WEBKIT_DOWNLOAD(obj);
-    WebKitURIResponse *resp;
-    GtkToolItem *tb = GTK_TOOL_ITEM(data);
-    gdouble p, size_mb;
-    const gchar *uri;
-    gchar *t, *filename, *base;
-
-    p = webkit_download_get_estimated_progress(download);
-    p = p > 1 ? 1 : p;
-    p = p < 0 ? 0 : p;
-    p *= 100;
-    resp = webkit_download_get_response(download);
-    size_mb = webkit_uri_response_get_content_length(resp) / 1e6;
-
-    uri = webkit_download_get_destination(download);
-    filename = g_filename_from_uri(uri, NULL, NULL);
-    if (filename == NULL)
-    {
-        /* This really should not happen because WebKit uses that URI to
-         * write to a file... */
-        fprintf(stderr, __NAME__": Could not construct file name from URI!\n");
-        t = g_strdup_printf("%s (%.0f%% of %.1f MB)",
-                            webkit_uri_response_get_uri(resp), p, size_mb);
-    }
-    else
-    {
-        base = g_path_get_basename(filename);
-        t = g_strdup_printf("%s (%.0f%% of %.1f MB)", base, p, size_mb);
-        g_free(filename);
-        g_free(base);
-    }
-    gtk_tool_button_set_label(GTK_TOOL_BUTTON(tb), t);
-    g_free(t);
+       WebKitDownload *download = WEBKIT_DOWNLOAD(obj);
+       WebKitURIResponse *resp;
+       GtkToolItem *tb = GTK_TOOL_ITEM(data);
+       gdouble p, size_mb;
+       const gchar *uri;
+       gchar *t, *filename, *base;
+
+       p = webkit_download_get_estimated_progress(download);
+       p = p > 1 ? 1 : p;
+       p = p < 0 ? 0 : p;
+       p *= 100;
+       resp = webkit_download_get_response(download);
+       size_mb = webkit_uri_response_get_content_length(resp) / 1e6;
+
+       uri = webkit_download_get_destination(download);
+       filename = g_filename_from_uri(uri, NULL, NULL);
+       if (filename == NULL) {
+               /* This really should not happen because WebKit uses that URI to
+                * write to a file... */
+               fprintf(stderr, __NAME__": Could not construct file name from URI!\n");
+               t = g_strdup_printf("%s (%.0f%% of %.1f MB)",
+                                                                                               webkit_uri_response_get_uri(resp), p, size_mb);
+       } else {
+               base = g_path_get_basename(filename);
+               t = g_strdup_printf("%s (%.0f%% of %.1f MB)", base, p, size_mb);
+               g_free(filename);
+               g_free(base);
+       }
+       gtk_tool_button_set_label(GTK_TOOL_BUTTON(tb), t);
+       g_free(t);
 }
 
 void
 changed_load_progress(GObject *obj, GParamSpec *pspec, gpointer data)
 {
-    struct Client *c = (struct Client *)data;
-    gdouble p;
-    gchar *grab_feeds =
-        "a = document.querySelectorAll('"
-        "    html > head > link[rel=\"alternate\"][href][type=\"application/atom+xml\"],"
-        "    html > head > link[rel=\"alternate\"][href][type=\"application/rss+xml\"]"
-        "');"
-        "if (a.length == 0)"
-        "    null;"
-        "else"
-        "{"
-        "    out = '';"
-        "    for (i = 0; i < a.length; i++)"
-        "    {"
-        "        url = encodeURIComponent(a[i].href);"
-        "        if ('title' in a[i] && a[i].title != '')"
-        "            title = encodeURIComponent(a[i].title);"
-        "        else"
-        "            title = url;"
-        "        out += '<li><a href=\"' + url + '\">' + title + '</a></li>';"
-        "    }"
-        "    out;"
-        "}";
-
-    p = webkit_web_view_get_estimated_load_progress(WEBKIT_WEB_VIEW(c->web_view));
-    if (p == 1)
-    {
-        p = 0;
-
-        /* The page has loaded fully. We now run the short JavaScript
-         * snippet above that operates on the DOM. It tries to grab all
-         * occurences of <link rel="alternate" ...>, i.e. RSS/Atom feed
-         * references. */
-        webkit_web_view_run_javascript(WEBKIT_WEB_VIEW(c->web_view),
-                                       grab_feeds, NULL,
-                                       grab_feeds_finished, c);
-
-        run_user_scripts(WEBKIT_WEB_VIEW(c->web_view));
-    }
-    gtk_entry_set_progress_fraction(GTK_ENTRY(c->location), p);
+       struct Client *c = (struct Client *)data;
+       gdouble p;
+       gchar *grab_feeds =
+               "a = document.querySelectorAll('"
+               "    html > head > link[rel=\"alternate\"][href][type=\"application/atom+xml\"],"
+               "    html > head > link[rel=\"alternate\"][href][type=\"application/rss+xml\"]"
+               "');"
+               "if (a.length == 0)"
+               "    null;"
+               "else"
+               "{"
+               "    out = '';"
+               "    for (i = 0; i < a.length; i++)"
+               "    {"
+               "        url = encodeURIComponent(a[i].href);"
+               "        if ('title' in a[i] && a[i].title != '')"
+               "            title = encodeURIComponent(a[i].title);"
+               "        else"
+               "            title = url;"
+               "        out += '<li><a href=\"' + url + '\">' + title + '</a></li>';"
+               "    }"
+               "    out;"
+               "}";
+
+
+       p = webkit_web_view_get_estimated_load_progress(WEBKIT_WEB_VIEW(c->web_view));
+       if (p == 1) {
+               p = 0;
+
+               /* The page has loaded fully. We now run the short JavaScript
+                * snippet above that operates on the DOM. It tries to grab all
+                * occurences of <link rel="alternate" ...>, i.e. RSS/Atom feed
+                * references. */
+               webkit_web_view_run_javascript(WEBKIT_WEB_VIEW(c->web_view),
+                                                                                                                                        grab_feeds, NULL,
+                                                                                                                                        grab_feeds_finished, c);
+
+               run_user_scripts(WEBKIT_WEB_VIEW(c->web_view));
+       }
+       gtk_entry_set_progress_fraction(GTK_ENTRY(c->location), p);
 }
 
 void
 changed_favicon(GObject *obj, GParamSpec *pspec, gpointer data)
 {
-    struct Client *c = (struct Client *)data;
-    cairo_surface_t *f;
-    int w, h, w_should, h_should;
-    GdkPixbuf *pb, *pb_scaled;
-
-    f = webkit_web_view_get_favicon(WEBKIT_WEB_VIEW(c->web_view));
-    if (f == NULL)
-    {
-        gtk_image_set_from_icon_name(GTK_IMAGE(c->tabicon), "text-html",
-                                     GTK_ICON_SIZE_SMALL_TOOLBAR);
-    }
-    else
-    {
-        w = cairo_image_surface_get_width(f);
-        h = cairo_image_surface_get_height(f);
-        pb = gdk_pixbuf_get_from_surface(f, 0, 0, w, h);
-        if (pb != NULL)
-        {
-            w_should = 16 * gtk_widget_get_scale_factor(c->tabicon);
-            h_should = 16 * gtk_widget_get_scale_factor(c->tabicon);
-            pb_scaled = gdk_pixbuf_scale_simple(pb, w_should, h_should,
-                                                GDK_INTERP_BILINEAR);
-            gtk_image_set_from_pixbuf(GTK_IMAGE(c->tabicon), pb_scaled);
-
-            g_object_unref(pb_scaled);
-            g_object_unref(pb);
-        }
-    }
+       struct Client *c = (struct Client *)data;
+       cairo_surface_t *f;
+       int w, h, w_should, h_should;
+       GdkPixbuf *pb, *pb_scaled;
+
+       f = webkit_web_view_get_favicon(WEBKIT_WEB_VIEW(c->web_view));
+       if (f == NULL) {
+               gtk_image_set_from_icon_name(GTK_IMAGE(c->tabicon), "text-html",
+                                                                                                                                GTK_ICON_SIZE_SMALL_TOOLBAR);
+       } else {
+               w = cairo_image_surface_get_width(f);
+               h = cairo_image_surface_get_height(f);
+               pb = gdk_pixbuf_get_from_surface(f, 0, 0, w, h);
+               if (pb != NULL) {
+                       w_should = 16 * gtk_widget_get_scale_factor(c->tabicon);
+                       h_should = 16 * gtk_widget_get_scale_factor(c->tabicon);
+                       pb_scaled = gdk_pixbuf_scale_simple(pb, w_should, h_should,
+                                                                                                                                                                       GDK_INTERP_BILINEAR);
+                       gtk_image_set_from_pixbuf(GTK_IMAGE(c->tabicon), pb_scaled);
+
+                       g_object_unref(pb_scaled);
+                       g_object_unref(pb);
+               }
+       }
 }
 
 void
 changed_title(GObject *obj, GParamSpec *pspec, gpointer data)
 {
-    const gchar *t, *u;
-    struct Client *c = (struct Client *)data;
+       const gchar *t, *u;
+       struct Client *c = (struct Client *)data;
 
-    u = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view));
-    t = webkit_web_view_get_title(WEBKIT_WEB_VIEW(c->web_view));
+       u = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view));
+       t = webkit_web_view_get_title(WEBKIT_WEB_VIEW(c->web_view));
 
-    u = u == NULL ? __NAME__ : u;
-    u = u[0] == 0 ? __NAME__ : u;
+       u = u == NULL ? __NAME__ : u;
+       u = u[0] == 0 ? __NAME__ : u;
 
-    t = t == NULL ? u : t;
-    t = t[0] == 0 ? u : t;
+       t = t == NULL ? u : t;
+       t = t[0] == 0 ? u : t;
 
-    gtk_label_set_text(GTK_LABEL(c->tablabel), t);
-    gtk_widget_set_tooltip_text(c->tablabel, t);
-    mainwindow_title(gtk_notebook_get_current_page(GTK_NOTEBOOK(mw.notebook)));
+       gtk_label_set_text(GTK_LABEL(c->tablabel), t);
+       gtk_widget_set_tooltip_text(c->tablabel, t);
+       mainwindow_title(gtk_notebook_get_current_page(GTK_NOTEBOOK(mw.notebook)));
 }
 
 void
 changed_uri(GObject *obj, GParamSpec *pspec, gpointer data)
 {
-    const gchar *t;
-    struct Client *c = (struct Client *)data;
-    FILE *fp;
-
-    t = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view));
-
-    /* When a web process crashes, we get a "notify::uri" signal, but we
-     * can no longer read a meaningful URI. It's just an empty string
-     * now. Not updating the location bar in this scenario is important,
-     * because we would override the "WEB PROCESS CRASHED" message. */
-    if (t != NULL && strlen(t) > 0)
-    {
-        gtk_entry_set_text(GTK_ENTRY(c->location), t);
-
-        if (history_file != NULL)
-        {
-            fp = fopen(history_file, "a");
-            if (fp != NULL)
-            {
-                fprintf(fp, "%s\n", t);
-                fclose(fp);
-            }
-            else
-                perror(__NAME__": Error opening history file");
-        }
-    }
+       const gchar *t;
+       struct Client *c = (struct Client *)data;
+       FILE *fp;
+
+       t = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view));
+
+       /* When a web process crashes, we get a "notify::uri" signal, but we
+        * can no longer read a meaningful URI. It's just an empty string
+        * now. Not updating the location bar in this scenario is important,
+        * because we would override the "WEB PROCESS CRASHED" message. */
+       if (t != NULL && strlen(t) > 0) {
+               gtk_entry_set_text(GTK_ENTRY(c->location), t);
+
+               if (history_file != NULL) {
+                       fp = fopen(history_file, "a");
+                       if (fp != NULL) {
+                               fprintf(fp, "%s\n", t);
+                               fclose(fp);
+                       } else {
+                               perror(__NAME__": Error opening history file");
+                       }
+               }
+       }
 }
 
 gboolean
 crashed_web_view(WebKitWebView *web_view, gpointer data)
 {
-    gchar *t;
-    struct Client *c = (struct Client *)data;
+       gchar *t;
+       struct Client *c = (struct Client *)data;
 
-    t = g_strdup_printf("WEB PROCESS CRASHED: %s",
-                        webkit_web_view_get_uri(WEBKIT_WEB_VIEW(web_view)));
-    gtk_entry_set_text(GTK_ENTRY(c->location), t);
-    g_free(t);
+       t = g_strdup_printf("WEB PROCESS CRASHED: %s",
+                                                                                       webkit_web_view_get_uri(WEBKIT_WEB_VIEW(web_view)));
+       gtk_entry_set_text(GTK_ENTRY(c->location), t);
+       g_free(t);
 
-    return TRUE;
+       return TRUE;
 }
 
 gboolean
 decide_policy(WebKitWebView *web_view, WebKitPolicyDecision *decision,
-              WebKitPolicyDecisionType type, gpointer data)
+                                                       WebKitPolicyDecisionType type, gpointer data)
 {
-    WebKitResponsePolicyDecision *r;
-
-    switch (type)
-    {
-        case WEBKIT_POLICY_DECISION_TYPE_RESPONSE:
-            r = WEBKIT_RESPONSE_POLICY_DECISION(decision);
-            if (!webkit_response_policy_decision_is_mime_type_supported(r))
-                webkit_policy_decision_download(decision);
-            else
-                webkit_policy_decision_use(decision);
-            break;
-        default:
-            /* Use whatever default there is. */
-            return FALSE;
-    }
-    return TRUE;
+       WebKitResponsePolicyDecision *r;
+
+       switch (type) {
+       case WEBKIT_POLICY_DECISION_TYPE_RESPONSE:
+               r = WEBKIT_RESPONSE_POLICY_DECISION(decision);
+               if (!webkit_response_policy_decision_is_mime_type_supported(r))
+                       webkit_policy_decision_download(decision);
+               else
+                       webkit_policy_decision_use(decision);
+               break;
+       default:
+               /* Use whatever default there is. */
+               return FALSE;
+       }
+       return TRUE;
 }
 
 void
 download_handle_finished(WebKitDownload *download, gpointer data)
 {
-    downloads--;
+       downloads--;
 }
 
 void
 download_handle_start(WebKitWebView *web_view, WebKitDownload *download,
-                      gpointer data)
+                                                                                       gpointer data)
 {
-    g_signal_connect(G_OBJECT(download), "decide-destination",
-                     G_CALLBACK(download_handle), data);
+       g_signal_connect(G_OBJECT(download), "decide-destination",
+                                                                        G_CALLBACK(download_handle), data);
 }
 
 gboolean
 download_handle(WebKitDownload *download, gchar *suggested_filename, gpointer data)
 {
-    gchar *sug_clean, *path, *path2 = NULL, *uri;
-    GtkToolItem *tb;
-    int suffix = 1;
-    size_t i;
-
-    sug_clean = g_strdup(suggested_filename);
-    for (i = 0; i < strlen(sug_clean); i++)
-        if (sug_clean[i] == G_DIR_SEPARATOR)
-            sug_clean[i] = '_';
-
-    path = g_build_filename(download_dir, sug_clean, NULL);
-    path2 = g_strdup(path);
-    while (g_file_test(path2, G_FILE_TEST_EXISTS) && suffix < 1000)
-    {
-        g_free(path2);
-
-        path2 = g_strdup_printf("%s.%d", path, suffix);
-        suffix++;
-    }
-
-    if (suffix == 1000)
-    {
-        fprintf(stderr, __NAME__": Suffix reached limit for download.\n");
-        webkit_download_cancel(download);
-    }
-    else
-    {
-        uri = g_filename_to_uri(path2, NULL, NULL);
-        webkit_download_set_destination(download, uri);
-        g_free(uri);
-
-        tb = gtk_tool_button_new(NULL, NULL);
-        gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(tb), "gtk-delete");
-        gtk_tool_button_set_label(GTK_TOOL_BUTTON(tb), sug_clean);
-        gtk_toolbar_insert(GTK_TOOLBAR(dm.toolbar), tb, 0);
-        gtk_widget_show_all(dm.win);
-
-        g_signal_connect(G_OBJECT(download), "notify::estimated-progress",
-                         G_CALLBACK(changed_download_progress), tb);
-
-        downloads++;
-        g_signal_connect(G_OBJECT(download), "finished",
-                         G_CALLBACK(download_handle_finished), NULL);
-
-        g_object_ref(download);
-        g_signal_connect(G_OBJECT(tb), "clicked",
-                         G_CALLBACK(downloadmanager_cancel), download);
-    }
-
-    g_free(sug_clean);
-    g_free(path);
-    g_free(path2);
-
-    /* Propagate -- to whom it may concern. */
-    return FALSE;
+       gchar *sug_clean, *path, *path2 = NULL, *uri;
+       GtkToolItem *tb;
+       int suffix = 1;
+       size_t i;
+
+       sug_clean = g_strdup(suggested_filename);
+       for (i = 0; i < strlen(sug_clean); i++)
+               if (sug_clean[i] == G_DIR_SEPARATOR)
+                       sug_clean[i] = '_';
+
+       path = g_build_filename(download_dir, sug_clean, NULL);
+       path2 = g_strdup(path);
+       while (g_file_test(path2, G_FILE_TEST_EXISTS) && suffix < 1000) {
+               g_free(path2);
+
+               path2 = g_strdup_printf("%s.%d", path, suffix);
+               suffix++;
+       }
+
+       if (suffix == 1000) {
+               fprintf(stderr, __NAME__": Suffix reached limit for download.\n");
+               webkit_download_cancel(download);
+       } else {
+               uri = g_filename_to_uri(path2, NULL, NULL);
+               webkit_download_set_destination(download, uri);
+               g_free(uri);
+
+               tb = gtk_tool_button_new(NULL, NULL);
+               gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(tb), "gtk-delete");
+               gtk_tool_button_set_label(GTK_TOOL_BUTTON(tb), sug_clean);
+               gtk_toolbar_insert(GTK_TOOLBAR(dm.toolbar), tb, 0);
+               gtk_widget_show_all(dm.win);
+
+               g_signal_connect(G_OBJECT(download), "notify::estimated-progress",
+                                                                                G_CALLBACK(changed_download_progress), tb);
+
+               downloads++;
+               g_signal_connect(G_OBJECT(download), "finished",
+                                                                                G_CALLBACK(download_handle_finished), NULL);
+
+               g_object_ref(download);
+               g_signal_connect(G_OBJECT(tb), "clicked",
+                                                                                G_CALLBACK(downloadmanager_cancel), download);
+       }
+
+       g_free(sug_clean);
+       g_free(path);
+       g_free(path2);
+
+       /* Propagate -- to whom it may concern. */
+       return FALSE;
 }
 
 void
 downloadmanager_cancel(GtkToolButton *tb, gpointer data)
 {
-    WebKitDownload *download = WEBKIT_DOWNLOAD(data);
+       WebKitDownload *download = WEBKIT_DOWNLOAD(data);
 
-    webkit_download_cancel(download);
-    g_object_unref(download);
+       webkit_download_cancel(download);
+       g_object_unref(download);
 
-    gtk_widget_destroy(GTK_WIDGET(tb));
+       gtk_widget_destroy(GTK_WIDGET(tb));
 }
 
 gboolean
 downloadmanager_delete(GtkWidget *obj, gpointer data)
 {
-    if (!quit_if_nothing_active())
-        gtk_widget_hide(dm.win);
+       if (!quit_if_nothing_active())
+               gtk_widget_hide(dm.win);
 
-    return TRUE;
+       return TRUE;
 }
 
 void
 downloadmanager_setup(void)
 {
-    dm.win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-    gtk_window_set_type_hint(GTK_WINDOW(dm.win), GDK_WINDOW_TYPE_HINT_DIALOG);
-    gtk_window_set_default_size(GTK_WINDOW(dm.win), 500, 250);
-    gtk_window_set_title(GTK_WINDOW(dm.win), __NAME__" - Download Manager");
-    g_signal_connect(G_OBJECT(dm.win), "delete-event",
-                     G_CALLBACK(downloadmanager_delete), NULL);
-    g_signal_connect(G_OBJECT(dm.win), "key-press-event",
-                     G_CALLBACK(key_downloadmanager), NULL);
-
-    dm.toolbar = gtk_toolbar_new();
-    gtk_orientable_set_orientation(GTK_ORIENTABLE(dm.toolbar),
-                                   GTK_ORIENTATION_VERTICAL);
-    gtk_toolbar_set_style(GTK_TOOLBAR(dm.toolbar), GTK_TOOLBAR_BOTH_HORIZ);
-    gtk_toolbar_set_show_arrow(GTK_TOOLBAR(dm.toolbar), FALSE);
-
-    dm.scroll = gtk_scrolled_window_new(NULL, NULL);
-    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(dm.scroll),
-                                   GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-    gtk_container_add(GTK_CONTAINER(dm.scroll), dm.toolbar);
-
-    gtk_container_add(GTK_CONTAINER(dm.win), dm.scroll);
+       dm.win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+       gtk_window_set_type_hint(GTK_WINDOW(dm.win), GDK_WINDOW_TYPE_HINT_DIALOG);
+       gtk_window_set_default_size(GTK_WINDOW(dm.win), 500, 250);
+       gtk_window_set_title(GTK_WINDOW(dm.win), __NAME__" - Download Manager");
+       g_signal_connect(G_OBJECT(dm.win), "delete-event",
+                                                                        G_CALLBACK(downloadmanager_delete), NULL);
+       g_signal_connect(G_OBJECT(dm.win), "key-press-event",
+                                                                        G_CALLBACK(key_downloadmanager), NULL);
+
+       dm.toolbar = gtk_toolbar_new();
+       gtk_orientable_set_orientation(GTK_ORIENTABLE(dm.toolbar),
+                                                                                                                                GTK_ORIENTATION_VERTICAL);
+       gtk_toolbar_set_style(GTK_TOOLBAR(dm.toolbar), GTK_TOOLBAR_BOTH_HORIZ);
+       gtk_toolbar_set_show_arrow(GTK_TOOLBAR(dm.toolbar), FALSE);
+
+       dm.scroll = gtk_scrolled_window_new(NULL, NULL);
+       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(dm.scroll),
+                                                                                                                                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+       gtk_container_add(GTK_CONTAINER(dm.scroll), dm.toolbar);
+
+       gtk_container_add(GTK_CONTAINER(dm.win), dm.scroll);
 }
 
 gchar *
 ensure_uri_scheme(const gchar *t)
 {
-    gchar *f, *fabs;
-
-    f = g_ascii_strdown(t, -1);
-    if (!g_str_has_prefix(f, "http:") &&
-        !g_str_has_prefix(f, "https:") &&
-        !g_str_has_prefix(f, "file:") &&
-        !g_str_has_prefix(f, "about:") &&
-        !g_str_has_prefix(f, "data:") &&
-        !g_str_has_prefix(f, "webkit:"))
-    {
-        g_free(f);
-        fabs = realpath(t, NULL);
-        if (fabs != NULL)
-        {
-            f = g_strdup_printf("file://%s", fabs);
-            free(fabs);
-        }
-        else
-            f = g_strdup_printf("http://%s", t);
-        return f;
-    }
-    else
-        return g_strdup(t);
+       gchar *f, *fabs;
+
+       f = g_ascii_strdown(t, -1);
+       if (!g_str_has_prefix(f, "http:") &&
+                       !g_str_has_prefix(f, "https:") &&
+                       !g_str_has_prefix(f, "file:") &&
+                       !g_str_has_prefix(f, "about:") &&
+                       !g_str_has_prefix(f, "data:") &&
+                       !g_str_has_prefix(f, "webkit:")) {
+               g_free(f);
+               fabs = realpath(t, NULL);
+               if (fabs != NULL) {
+                       f = g_strdup_printf("file://%s", fabs);
+                       free(fabs);
+               } else {
+                       f = g_strdup_printf("http://%s", t);
+               }
+               return f;
+       } else
+               return g_strdup(t);
 }
 
 void
 grab_environment_configuration(void)
 {
-    const gchar *e;
-
-    e = g_getenv(__NAME_UPPERCASE__"_ACCEPTED_LANGUAGE");
-    if (e != NULL)
-        accepted_language[0] = g_strdup(e);
-
-    e = g_getenv(__NAME_UPPERCASE__"_DOWNLOAD_DIR");
-    if (e != NULL)
-        download_dir = g_strdup(e);
-
-    e = g_getenv(__NAME_UPPERCASE__"_ENABLE_CONSOLE_TO_STDOUT");
-    if (e != NULL)
-        enable_console_to_stdout = TRUE;
-
-    e = g_getenv(__NAME_UPPERCASE__"_FIFO_SUFFIX");
-    if (e != NULL)
-        fifo_suffix = g_strdup(e);
-
-    e = g_getenv(__NAME_UPPERCASE__"_HISTORY_FILE");
-    if (e != NULL)
-        history_file = g_strdup(e);
-
-    e = g_getenv(__NAME_UPPERCASE__"_HOME_URI");
-    if (e != NULL)
-        home_uri = g_strdup(e);
-
-    e = g_getenv(__NAME_UPPERCASE__"_TAB_POS");
-    if (e != NULL)
-    {
-        if (strcmp(e, "top") == 0)
-            tab_pos = GTK_POS_TOP;
-        if (strcmp(e, "right") == 0)
-            tab_pos = GTK_POS_RIGHT;
-        if (strcmp(e, "bottom") == 0)
-            tab_pos = GTK_POS_BOTTOM;
-        if (strcmp(e, "left") == 0)
-            tab_pos = GTK_POS_LEFT;
-    }
-
-    e = g_getenv(__NAME_UPPERCASE__"_TAB_WIDTH_CHARS");
-    if (e != NULL)
-        tab_width_chars = atoi(e);
-
-    e = g_getenv(__NAME_UPPERCASE__"_USER_AGENT");
-    if (e != NULL)
-        user_agent = g_strdup(e);
-
-    e = g_getenv(__NAME_UPPERCASE__"_ZOOM");
-    if (e != NULL)
-        global_zoom = atof(e);
+       const gchar *e;
+
+       e = g_getenv(__NAME_UPPERCASE__"_ACCEPTED_LANGUAGE");
+       if (e != NULL)
+               accepted_language[0] = g_strdup(e);
+
+       e = g_getenv(__NAME_UPPERCASE__"_DOWNLOAD_DIR");
+       if (e != NULL)
+               download_dir = g_strdup(e);
+
+       e = g_getenv(__NAME_UPPERCASE__"_ENABLE_CONSOLE_TO_STDOUT");
+       if (e != NULL)
+               enable_console_to_stdout = TRUE;
+
+       e = g_getenv(__NAME_UPPERCASE__"_FIFO_SUFFIX");
+       if (e != NULL)
+               fifo_suffix = g_strdup(e);
+
+       e = g_getenv(__NAME_UPPERCASE__"_HISTORY_FILE");
+       if (e != NULL)
+               history_file = g_strdup(e);
+
+       e = g_getenv(__NAME_UPPERCASE__"_HOME_URI");
+       if (e != NULL)
+               home_uri = g_strdup(e);
+
+       e = g_getenv(__NAME_UPPERCASE__"_TAB_POS");
+       if (e != NULL) {
+               if (strcmp(e, "top") == 0)
+                       tab_pos = GTK_POS_TOP;
+               if (strcmp(e, "right") == 0)
+                       tab_pos = GTK_POS_RIGHT;
+               if (strcmp(e, "bottom") == 0)
+                       tab_pos = GTK_POS_BOTTOM;
+               if (strcmp(e, "left") == 0)
+                       tab_pos = GTK_POS_LEFT;
+       }
+
+       e = g_getenv(__NAME_UPPERCASE__"_TAB_WIDTH_CHARS");
+       if (e != NULL)
+               tab_width_chars = atoi(e);
+
+       e = g_getenv(__NAME_UPPERCASE__"_USER_AGENT");
+       if (e != NULL)
+               user_agent = g_strdup(e);
+
+       e = g_getenv(__NAME_UPPERCASE__"_ZOOM");
+       if (e != NULL)
+               global_zoom = atof(e);
 }
 
 void
 grab_feeds_finished(GObject *object, GAsyncResult *result, gpointer data)
 {
-    struct Client *c = (struct Client *)data;
-    WebKitJavascriptResult *js_result;
-    JSCValue *value;
-    JSCException *exception;
-    GError *err = NULL;
-    gchar *str_value;
-
-    g_free(c->feed_html);
-    c->feed_html = NULL;
-
-    /* This was taken almost verbatim from the example in WebKit's
-     * documentation:
-     *
-     * https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#webkit-web-view-run-javascript-finish */
-
-    js_result = webkit_web_view_run_javascript_finish(WEBKIT_WEB_VIEW(object),
-                                                      result, &err);
-    if (!js_result)
-    {
-        fprintf(stderr, __NAME__": Error running javascript: %s\n", err->message);
-        g_error_free(err);
-        return;
-    }
-
-    value = webkit_javascript_result_get_js_value(js_result);
-    if (jsc_value_is_string(value))
-    {
-        str_value = jsc_value_to_string(value);
-        exception = jsc_context_get_exception(jsc_value_get_context(value));
-        if (exception != NULL)
-        {
-            fprintf(stderr, __NAME__": Error running javascript: %s\n",
-                    jsc_exception_get_message(exception));
-        }
-        else
-            c->feed_html = str_value;
-
-        gtk_entry_set_icon_from_icon_name(GTK_ENTRY(c->location),
-                                          GTK_ENTRY_ICON_PRIMARY,
-                                          "application-rss+xml-symbolic");
-        gtk_entry_set_icon_activatable(GTK_ENTRY(c->location),
-                                       GTK_ENTRY_ICON_PRIMARY,
-                                       TRUE);
-    }
-    else
-    {
-        gtk_entry_set_icon_from_icon_name(GTK_ENTRY(c->location),
-                                          GTK_ENTRY_ICON_PRIMARY,
-                                          NULL);
-    }
-
-    webkit_javascript_result_unref(js_result);
+       struct Client *c = (struct Client *)data;
+       WebKitJavascriptResult *js_result;
+       JSCValue *value;
+       JSCException *exception;
+       GError *err = NULL;
+       gchar *str_value;
+
+       g_free(c->feed_html);
+       c->feed_html = NULL;
+
+       /* This was taken almost verbatim from the example in WebKit's
+        * documentation:
+        *
+        * https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#webkit-web-view-run-javascript-finish */
+
+       js_result = webkit_web_view_run_javascript_finish(WEBKIT_WEB_VIEW(object),
+                                                                                                                                                                                                               result, &err);
+       if (!js_result) {
+               fprintf(stderr, __NAME__": Error running javascript: %s\n", err->message);
+               g_error_free(err);
+               return;
+       }
+
+       value = webkit_javascript_result_get_js_value(js_result);
+       if (jsc_value_is_string(value)) {
+               str_value = jsc_value_to_string(value);
+               exception = jsc_context_get_exception(jsc_value_get_context(value));
+               if (exception != NULL) {
+                       fprintf(stderr, __NAME__": Error running javascript: %s\n",
+                                                       jsc_exception_get_message(exception));
+               } else {
+                       c->feed_html = str_value;
+               }
+
+               gtk_entry_set_icon_from_icon_name(GTK_ENTRY(c->location),
+                                                                                                                                                       GTK_ENTRY_ICON_PRIMARY,
+                                                                                                                                                       "application-rss+xml-symbolic");
+               gtk_entry_set_icon_activatable(GTK_ENTRY(c->location),
+                                                                                                                                        GTK_ENTRY_ICON_PRIMARY,
+                                                                                                                                        TRUE);
+       } else {
+               gtk_entry_set_icon_from_icon_name(GTK_ENTRY(c->location),
+                                                                                                                                                       GTK_ENTRY_ICON_PRIMARY,
+                                                                                                                                                       NULL);
+       }
+
+       webkit_javascript_result_unref(js_result);
 }
 
 void
 hover_web_view(WebKitWebView *web_view, WebKitHitTestResult *ht, guint modifiers,
-               gpointer data)
+                                                        gpointer data)
 {
-    struct Client *c = (struct Client *)data;
-    const char *to_show;
-
-    g_free(c->hover_uri);
-
-    if (webkit_hit_test_result_context_is_link(ht))
-    {
-        to_show = webkit_hit_test_result_get_link_uri(ht);
-        c->hover_uri = g_strdup(to_show);
-    }
-    else
-    {
-        to_show = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view));
-        c->hover_uri = NULL;
-    }
-
-    if (!gtk_widget_is_focus(c->location))
-        gtk_entry_set_text(GTK_ENTRY(c->location), to_show);
+       struct Client *c = (struct Client *)data;
+       const char *to_show;
+
+       g_free(c->hover_uri);
+
+       if (webkit_hit_test_result_context_is_link(ht)) {
+               to_show = webkit_hit_test_result_get_link_uri(ht);
+               c->hover_uri = g_strdup(to_show);
+       } else {
+               to_show = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view));
+               c->hover_uri = NULL;
+       }
+
+       if (!gtk_widget_is_focus(c->location))
+               gtk_entry_set_text(GTK_ENTRY(c->location), to_show);
 }
 
 void
 icon_location(GtkEntry *entry, GtkEntryIconPosition icon_pos, GdkEvent *event,
-              gpointer data)
+                                                       gpointer data)
 {
-    struct Client *c = (struct Client *)data;
-    gchar *d;
-    gchar *data_template =
-        "data:text/html,"
-        "<!DOCTYPE html>"
-        "<html>"
-        "    <head>"
-        "        <meta charset=\"UTF-8\">"
-        "        <title>Feeds</title>"
-        "    </head>"
-        "    <body>"
-        "        <p>Feeds found on this page:</p>"
-        "        <ul>"
-        "        %s"
-        "        </ul>"
-        "    </body>"
-        "</html>";
-
-    if (c->feed_html != NULL)
-    {
-        /* What we're actually trying to do is show a simple HTML page
-         * that lists all the feeds on the current page. The function
-         * webkit_web_view_load_html() looks like the proper way to do
-         * that. Sad thing is, it doesn't create a history entry, but
-         * instead simply replaces the content of the current page. This
-         * is not what we want.
-         *
-         * RFC 2397 [0] defines the data URI scheme [1]. We abuse this
-         * mechanism to show my custom HTML snippet *and* create a
-         * history entry.
-         *
-         * [0]: https://tools.ietf.org/html/rfc2397
-         * [1]: https://en.wikipedia.org/wiki/Data_URI_scheme */
-        d = g_strdup_printf(data_template, c->feed_html);
-        webkit_web_view_load_uri(WEBKIT_WEB_VIEW(c->web_view), d);
-        g_free(d);
-    }
+       struct Client *c = (struct Client *)data;
+       gchar *d;
+       gchar *data_template =
+               "data:text/html,"
+               "<!DOCTYPE html>"
+               "<html>"
+               "    <head>"
+               "        <meta charset=\"UTF-8\">"
+               "        <title>Feeds</title>"
+               "    </head>"
+               "    <body>"
+               "        <p>Feeds found on this page:</p>"
+               "        <ul>"
+               "        %s"
+               "        </ul>"
+               "    </body>"
+               "</html>";
+
+       if (c->feed_html != NULL)
+               {
+                       /* What we're actually trying to do is show a simple HTML page
+                        * that lists all the feeds on the current page. The function
+                        * webkit_web_view_load_html() looks like the proper way to do
+                        * that. Sad thing is, it doesn't create a history entry, but
+                        * instead simply replaces the content of the current page. This
+                        * is not what we want.
+                        *
+                        * RFC 2397 [0] defines the data URI scheme [1]. We abuse this
+                        * mechanism to show my custom HTML snippet *and* create a
+                        * history entry.
+                        *
+                        * [0]: https://tools.ietf.org/html/rfc2397
+                        * [1]: https://en.wikipedia.org/wiki/Data_URI_scheme */
+                       d = g_strdup_printf(data_template, c->feed_html);
+                       webkit_web_view_load_uri(WEBKIT_WEB_VIEW(c->web_view), d);
+                       g_free(d);
+               }
 }
 
 void
 init_default_web_context(void)
 {
-    gchar *p;
-    WebKitWebContext *wc;
+       gchar *p;
+       WebKitWebContext *wc;
+       WebKitCookieManager *cm;
+
+       wc = webkit_web_context_get_default();
 
-    wc = webkit_web_context_get_default();
+       p = g_build_filename(g_get_user_config_dir(), __NAME__, "adblock", NULL);
+       webkit_web_context_set_sandbox_enabled(wc, TRUE);
+       webkit_web_context_add_path_to_sandbox(wc, p, TRUE);
+       g_free(p);
 
-    p = g_build_filename(g_get_user_config_dir(), __NAME__, "adblock", NULL);
-    webkit_web_context_set_sandbox_enabled(wc, TRUE);
-    webkit_web_context_add_path_to_sandbox(wc, p, TRUE);
-    g_free(p);
+       webkit_web_context_set_process_model(wc,
+                                                                                                                                                        WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
 
-    webkit_web_context_set_process_model(wc,
-        WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
+       p = g_build_filename(g_get_user_config_dir(), __NAME__, "web_extensions",
+                                                                                        NULL);
+       webkit_web_context_set_web_extensions_directory(wc, p);
+       g_free(p);
 
-    p = g_build_filename(g_get_user_config_dir(), __NAME__, "web_extensions",
-                         NULL);
-    webkit_web_context_set_web_extensions_directory(wc, p);
-    g_free(p);
+       if (accepted_language[0] != NULL)
+               webkit_web_context_set_preferred_languages(wc, accepted_language);
 
-    if (accepted_language[0] != NULL)
-        webkit_web_context_set_preferred_languages(wc, accepted_language);
+       g_signal_connect(G_OBJECT(wc), "download-started",
+                                                                        G_CALLBACK(download_handle_start), NULL);
 
-    g_signal_connect(G_OBJECT(wc), "download-started",
-                     G_CALLBACK(download_handle_start), NULL);
+       trust_user_certs(wc);
 
-    trust_user_certs(wc);
+       cm = webkit_web_context_get_cookie_manager(wc);
+       webkit_cookie_manager_set_accept_policy(cm, WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY);
+
+       webkit_web_context_set_favicon_database_directory(wc, NULL);
+       webkit_cookie_manager_set_persistent_storage(cm,
+                                                                                                                                                                                        g_build_filename("/",
+                                                                                                                                                                                                                                                               g_get_user_cache_dir(),
+                                                                                                                                                                                                                                                               __NAME__,
+                                                                                                                                                                                                                                                               "cookies.db",
+                                                                                                                                                                                                                                                               NULL),
+                                                                                                                                                                                        WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE);
+}
+
+void
+search(gpointer data, gint direction)
+{
+       struct Client *c = (struct Client *)data;
+       WebKitWebView *web_view = WEBKIT_WEB_VIEW(c->web_view);
+       WebKitFindController *fc = webkit_web_view_get_find_controller(web_view);
+
+       if (search_text == NULL)
+               return;
+
+       switch (direction) {
+       case 0:
+               webkit_find_controller_search(fc, search_text,
+                                                                                                                                       WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
+                                                                                                                                       WEBKIT_FIND_OPTIONS_WRAP_AROUND,
+                                                                                                                                       G_MAXUINT);
+               break;
+       case 1:
+               webkit_find_controller_search_next(fc);
+               break;
+       case -1:
+               webkit_find_controller_search_previous(fc);
+               break;
+       case 2:
+               webkit_find_controller_search_finish(fc);
+               break;
+       }
+}
 
-    webkit_web_context_set_favicon_database_directory(wc, NULL);
+void
+search_init(struct Client *c, int direction)
+{
+       gtk_widget_grab_focus(c->location);
+       const gchar *contents = gtk_entry_get_text(GTK_ENTRY(c->location));
+       if (strcspn(contents, "s/")) {
+               gtk_entry_set_text(GTK_ENTRY(c->location), "s/");
+       }
+       gtk_editable_set_position(GTK_EDITABLE(c->location), -1);
+       search(c, 0);
+       search(c, -1);
+       search(c, direction);
 }
 
 gboolean
 key_common(GtkWidget *widget, GdkEvent *event, gpointer data)
 {
-    struct Client *c = (struct Client *)data;
-    WebKitWebContext *wc = webkit_web_view_get_context(WEBKIT_WEB_VIEW(c->web_view));
-    gchar *f;
-
-    if (event->type == GDK_KEY_PRESS)
-    {
-        if (((GdkEventKey *)event)->state & GDK_MOD1_MASK)
-        {
-            switch (((GdkEventKey *)event)->keyval)
-            {
-                case GDK_KEY_q:  /* close window (left hand) */
-                    client_destroy(NULL, c);
-                    return TRUE;
-                case GDK_KEY_w:  /* home (left hand) */
-                    f = ensure_uri_scheme(home_uri);
-                    webkit_web_view_load_uri(WEBKIT_WEB_VIEW(c->web_view), f);
-                    g_free(f);
-                    return TRUE;
-                case GDK_KEY_e:  /* new tab (left hand) */
-                    f = ensure_uri_scheme(home_uri);
-                    client_new(f, NULL, TRUE, TRUE);
-                    g_free(f);
-                    return TRUE;
-                case GDK_KEY_r:  /* reload (left hand) */
-                    webkit_web_view_reload_bypass_cache(WEBKIT_WEB_VIEW(
-                                                        c->web_view));
-                    return TRUE;
-                case GDK_KEY_d:  /* download manager (left hand) */
-                    gtk_widget_show_all(dm.win);
-                    return TRUE;
-                case GDK_KEY_2:  /* search forward (left hand) */
-                case GDK_KEY_n:  /* search forward (maybe both hands) */
-                    search(c, 1);
-                    return TRUE;
-                case GDK_KEY_3:  /* search backward (left hand) */
-                    search(c, -1);
-                    return TRUE;
-                case GDK_KEY_l:  /* location (BOTH hands) */
-                    gtk_widget_grab_focus(c->location);
-                    return TRUE;
-                case GDK_KEY_k:  /* initiate search (BOTH hands) */
-                    gtk_widget_grab_focus(c->location);
-                    gtk_entry_set_text(GTK_ENTRY(c->location), ":/");
-                    gtk_editable_set_position(GTK_EDITABLE(c->location), -1);
-                    return TRUE;
-                case GDK_KEY_c:  /* reload trusted certs (left hand) */
-                    trust_user_certs(wc);
-                    return TRUE;
-                case GDK_KEY_a:  /* go one tab to the left (left hand) */
-                    gtk_notebook_prev_page(GTK_NOTEBOOK(mw.notebook));
-                    return TRUE;
-                case GDK_KEY_s:  /* go one tab to the right (left hand) */
-                    gtk_notebook_next_page(GTK_NOTEBOOK(mw.notebook));
-                    return TRUE;
-            }
-        }
-        /* navigate backward (left hand) */
-        else if (((GdkEventKey *)event)->keyval == GDK_KEY_F2)
-        {
-            webkit_web_view_go_back(WEBKIT_WEB_VIEW(c->web_view));
-            return TRUE;
-        }
-        /* navigate forward (left hand) */
-        else if (((GdkEventKey *)event)->keyval == GDK_KEY_F3)
-        {
-            webkit_web_view_go_forward(WEBKIT_WEB_VIEW(c->web_view));
-            return TRUE;
-        }
-    }
-
-    return FALSE;
+       struct Client *c = (struct Client *)data;
+       gdouble now;
+       gchar *f;
+
+       if (event->type == GDK_KEY_PRESS) {
+               if (((GdkEventKey *)event)->state & GDK_CONTROL_MASK) {
+                       switch (((GdkEventKey *)event)->keyval) {
+                       case GDK_KEY_q:  // close window
+                               client_destroy(NULL, c);
+                               return TRUE;
+                       case GDK_KEY_w:  // new tab
+                               f = ensure_uri_scheme(home_uri);
+                               client_new(f, NULL, TRUE, TRUE);
+                               g_free(f);
+                               return TRUE;
+                       case GDK_KEY_e:  // reload
+                               webkit_web_view_reload_bypass_cache(WEBKIT_WEB_VIEW(c->web_view));
+                               return TRUE;
+                       case GDK_KEY_y:  // download manager
+                               gtk_widget_show_all(dm.win);
+                               return TRUE;
+                       case GDK_KEY_d:  // initiate web search
+                               gtk_widget_grab_focus(c->location);
+                               gtk_entry_set_text(GTK_ENTRY(c->location), "w/");
+                               gtk_editable_set_position(GTK_EDITABLE(c->location), -1);
+                               return TRUE;
+                       case GDK_KEY_s:  // i-search forwards
+                               search_init(c, 1);
+                               return TRUE;
+                       case GDK_KEY_r:  // i-search backwards
+                               search_init(c, -1);
+                               return TRUE;
+                       case GDK_KEY_t:  // location
+                               gtk_widget_grab_focus(c->location);
+                               gtk_entry_set_text(GTK_ENTRY(c->location),
+                                                                                                        webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view)));
+                               return TRUE;
+                       case GDK_KEY_u:  // previous tab
+                               gtk_notebook_prev_page(GTK_NOTEBOOK(mw.notebook));
+                               return TRUE;
+                       case GDK_KEY_i:  // next tab
+                               gtk_notebook_next_page(GTK_NOTEBOOK(mw.notebook));
+                               return TRUE;
+                       case GDK_KEY_h:  // back in history
+                               webkit_web_view_go_back(WEBKIT_WEB_VIEW(c->web_view));
+                               return TRUE;
+                       case GDK_KEY_l:  // forward in history
+                               webkit_web_view_go_forward(WEBKIT_WEB_VIEW(c->web_view));
+                               return TRUE;
+                       case GDK_KEY_j:  // scroll down
+                               for (int i = 0; i < 2; i++) {
+                                       event->key.keyval = GDK_KEY_Down;
+                                       gdk_event_put(event);
+                               }
+                               return TRUE;
+                       case GDK_KEY_k:  // scroll up
+                               for (int i = 0; i < 2; i++) {
+                                       event->key.keyval = GDK_KEY_Up;
+                                       gdk_event_put(event);
+                               }
+                               return TRUE;
+                       case GDK_KEY_f:  // page down
+                               event->key.keyval = GDK_KEY_Page_Down;
+                               gdk_event_put(event);
+                               return TRUE;
+                       case GDK_KEY_b:  // page up
+                               event->key.keyval = GDK_KEY_Page_Up;
+                               gdk_event_put(event);
+                               return TRUE;
+                       case GDK_KEY_o:  // toggle JS
+                               WebKitSettings *settings = webkit_web_view_get_settings(WEBKIT_WEB_VIEW(c->web_view));
+                               gboolean current = webkit_settings_get_enable_javascript(settings);
+                               webkit_settings_set_enable_javascript(settings,
+                                                                                                                                                                                       (current) ? FALSE : TRUE);
+                               webkit_web_view_set_settings(WEBKIT_WEB_VIEW(c->web_view), settings);
+                               return TRUE;
+                       case GDK_KEY_g:  // go to bottom
+                               search(c, 2);
+                               gtk_widget_grab_focus(c->web_view);
+                               gtk_entry_set_text(GTK_ENTRY(c->location),
+                                                                                                        webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view)));
+                               webkit_web_view_run_javascript(WEBKIT_WEB_VIEW(c->web_view),
+                                                                                                                                                        "window.getSelection().removeAllRanges();"
+                                                                                                                                                        "document.activeElement.blur();",
+                                                                                                                                                        NULL, NULL, c);
+                               return TRUE;
+                       case GDK_KEY_equal:  // zoom in
+                               now = webkit_web_view_get_zoom_level(WEBKIT_WEB_VIEW(c->web_view));
+                               webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(c->web_view), now + 0.1);
+                               return TRUE;
+                       case GDK_KEY_minus:  // zoom out
+                               now = webkit_web_view_get_zoom_level(WEBKIT_WEB_VIEW(c->web_view));
+                               webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(c->web_view), now - 0.1);
+                               return TRUE;
+                       case GDK_KEY_0:  // reset zoom
+                               webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(c->web_view), 1);
+                               return TRUE;
+                       }
+               }
+       }
+       return FALSE;
 }
 
 gboolean
 key_downloadmanager(GtkWidget *widget, GdkEvent *event, gpointer data)
 {
-    if (event->type == GDK_KEY_PRESS)
-    {
-        if (((GdkEventKey *)event)->state & GDK_MOD1_MASK)
-        {
-            switch (((GdkEventKey *)event)->keyval)
-            {
-                case GDK_KEY_d:  /* close window (left hand) */
-                case GDK_KEY_q:
-                    downloadmanager_delete(dm.win, NULL);
-                    return TRUE;
-            }
-        }
-    }
-
-    return FALSE;
+       if (event->type == GDK_KEY_PRESS) {
+               if (((GdkEventKey *)event)->state & GDK_CONTROL_MASK) {
+                       switch (((GdkEventKey *)event)->keyval) {
+                       case GDK_KEY_y:  /* close window (left hand) */
+                       case GDK_KEY_q:
+                               downloadmanager_delete(dm.win, NULL);
+                               return TRUE;
+                       }
+               }
+       }
+
+       return FALSE;
 }
 
 gboolean
 key_location(GtkWidget *widget, GdkEvent *event, gpointer data)
 {
-    struct Client *c = (struct Client *)data;
-    const gchar *t;
-    gchar *f;
-
-    if (key_common(widget, event, data))
-        return TRUE;
-
-    if (event->type == GDK_KEY_PRESS)
-    {
-        switch (((GdkEventKey *)event)->keyval)
-        {
-            case GDK_KEY_KP_Enter:
-            case GDK_KEY_Return:
-                gtk_widget_grab_focus(c->web_view);
-                t = gtk_entry_get_text(GTK_ENTRY(c->location));
-                if (t != NULL && t[0] == ':' && t[1] == '/')
-                {
-                    if (search_text != NULL)
-                        g_free(search_text);
-                    search_text = g_strdup(t + 2);
-                    search(c, 0);
-                }
-                else
-                {
-                    f = ensure_uri_scheme(t);
-                    webkit_web_view_load_uri(WEBKIT_WEB_VIEW(c->web_view), f);
-                    g_free(f);
-                }
-                return TRUE;
-            case GDK_KEY_Escape:
-                t = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view));
-                gtk_entry_set_text(GTK_ENTRY(c->location),
-                                   (t == NULL ? __NAME__ : t));
-                return TRUE;
-        }
-    }
-
-    return FALSE;
+       struct Client *c = (struct Client *)data;
+       const gchar *t;
+       gchar *f;
+
+       if (key_common(widget, event, data))
+               return TRUE;
+
+       if (event->type == GDK_KEY_PRESS) {
+               switch (((GdkEventKey *)event)->keyval) {
+               case GDK_KEY_KP_Enter:
+               case GDK_KEY_Return:
+                       gtk_widget_grab_focus(c->web_view);
+                       t = gtk_entry_get_text(GTK_ENTRY(c->location));
+                       if (t != NULL && t[0] == 's' && t[1] == '/') {
+                               if (search_text != NULL)
+                                       g_free(search_text);
+                               search_text = g_strdup(t + 2);
+                               search(c, 0);
+                       } else if (t != NULL && t[0] == 'w' && t[1] == '/') {
+                               const char *engine = "https://duckduckgo.com?q=";
+                               int len = strlen(engine) + strlen(t) - 2;
+                               char *f = (char *) malloc(len);
+                               snprintf(f, len + 1, "%s%s", engine, t + 2);
+                               webkit_web_view_load_uri(WEBKIT_WEB_VIEW(c->web_view), f);
+                               free(f);
+                       } else {
+                               f = ensure_uri_scheme(t);
+                               webkit_web_view_load_uri(WEBKIT_WEB_VIEW(c->web_view), f);
+                               g_free(f);
+                       }
+                       return TRUE;
+               case GDK_KEY_Escape:
+                       t = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view));
+                       gtk_entry_set_text(GTK_ENTRY(c->location),
+                                                                                                (t == NULL ? __NAME__ : t));
+                       return TRUE;
+               }
+       }
+
+       return FALSE;
 }
 
 gboolean
 key_tablabel(GtkWidget *widget, GdkEvent *event, gpointer data)
 {
-    GdkScrollDirection direction;
-
-    if (event->type == GDK_BUTTON_RELEASE)
-    {
-        switch (((GdkEventButton *)event)->button)
-        {
-            case 2:
-                client_destroy(NULL, data);
-                return TRUE;
-        }
-    }
-    else if (event->type == GDK_SCROLL)
-    {
-        gdk_event_get_scroll_direction(event, &direction);
-        switch (direction)
-        {
-            case GDK_SCROLL_UP:
-                gtk_notebook_prev_page(GTK_NOTEBOOK(mw.notebook));
-                break;
-            case GDK_SCROLL_DOWN:
-                gtk_notebook_next_page(GTK_NOTEBOOK(mw.notebook));
-                break;
-            default:
-                break;
-        }
-        return TRUE;
-    }
-    return FALSE;
+       GdkScrollDirection direction;
+
+       if (event->type == GDK_BUTTON_RELEASE) {
+               switch (((GdkEventButton *)event)->button) {
+               case 2:
+                       client_destroy(NULL, data);
+                       return TRUE;
+               }
+       } else if (event->type == GDK_SCROLL) {
+               gdk_event_get_scroll_direction(event, &direction);
+               switch (direction) {
+               case GDK_SCROLL_UP:
+                       gtk_notebook_prev_page(GTK_NOTEBOOK(mw.notebook));
+                       break;
+               case GDK_SCROLL_DOWN:
+                       gtk_notebook_next_page(GTK_NOTEBOOK(mw.notebook));
+                       break;
+               default:
+                       break;
+               }
+               return TRUE;
+       }
+       return FALSE;
 }
 
 gboolean
 key_web_view(GtkWidget *widget, GdkEvent *event, gpointer data)
 {
-    struct Client *c = (struct Client *)data;
-    gdouble dx, dy;
-    gfloat z;
-
-    if (key_common(widget, event, data))
-        return TRUE;
-
-    if (event->type == GDK_KEY_PRESS)
-    {
-        if (((GdkEventKey *)event)->keyval == GDK_KEY_Escape)
-        {
-            webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(c->web_view));
-            gtk_entry_set_progress_fraction(GTK_ENTRY(c->location), 0);
-        }
-    }
-    else if (event->type == GDK_BUTTON_RELEASE)
-    {
-        switch (((GdkEventButton *)event)->button)
-        {
-            case 2:
-                if (c->hover_uri != NULL)
-                {
-                    client_new(c->hover_uri, NULL, TRUE, FALSE);
-                    return TRUE;
-                }
-                break;
-            case 8:
-                webkit_web_view_go_back(WEBKIT_WEB_VIEW(c->web_view));
-                return TRUE;
-            case 9:
-                webkit_web_view_go_forward(WEBKIT_WEB_VIEW(c->web_view));
-                return TRUE;
-        }
-    }
-    else if (event->type == GDK_SCROLL)
-    {
-        if (((GdkEventScroll *)event)->state & GDK_MOD1_MASK ||
-            ((GdkEventScroll *)event)->state & GDK_CONTROL_MASK)
-        {
-            gdk_event_get_scroll_deltas(event, &dx, &dy);
-            z = webkit_web_view_get_zoom_level(WEBKIT_WEB_VIEW(c->web_view));
-            z += -dy * 0.1;
-            z = dx != 0 ? global_zoom : z;
-            webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(c->web_view), z);
-            return TRUE;
-        }
-    }
-
-    return FALSE;
+       struct Client *c = (struct Client *)data;
+       gdouble dx, dy;
+       gfloat z;
+
+       if (key_common(widget, event, data))
+               return TRUE;
+
+       if (event->type == GDK_KEY_PRESS) {
+               if (((GdkEventKey *)event)->keyval == GDK_KEY_Escape) {
+                       webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(c->web_view));
+                       gtk_entry_set_progress_fraction(GTK_ENTRY(c->location), 0);
+               }
+       } else if (event->type == GDK_BUTTON_RELEASE) {
+               switch (((GdkEventButton *)event)->button) {
+               case 2:
+                       if (c->hover_uri != NULL) {
+                               client_new(c->hover_uri, NULL, TRUE, FALSE);
+                               return TRUE;
+                       }
+                       break;
+               case 8:
+                       webkit_web_view_go_back(WEBKIT_WEB_VIEW(c->web_view));
+                       return TRUE;
+               case 9:
+                       webkit_web_view_go_forward(WEBKIT_WEB_VIEW(c->web_view));
+                       return TRUE;
+               }
+       } else if (event->type == GDK_SCROLL) {
+               if (((GdkEventScroll *)event)->state & GDK_CONTROL_MASK ||
+                               ((GdkEventScroll *)event)->state & GDK_CONTROL_MASK) {
+                       gdk_event_get_scroll_deltas(event, &dx, &dy);
+                       z = webkit_web_view_get_zoom_level(WEBKIT_WEB_VIEW(c->web_view));
+                       z += -dy * 0.1;
+                       z = dx != 0 ? global_zoom : z;
+                       webkit_web_view_set_zoom_level(WEBKIT_WEB_VIEW(c->web_view), z);
+                       return TRUE;
+               }
+       }
+
+       return FALSE;
 }
 
 void
 mainwindow_setup(void)
 {
-    mw.win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-    gtk_window_set_default_size(GTK_WINDOW(mw.win), 800, 600);
-    g_signal_connect(G_OBJECT(mw.win), "destroy", gtk_main_quit, NULL);
-    gtk_window_set_title(GTK_WINDOW(mw.win), __NAME__);
-
-    mw.notebook = gtk_notebook_new();
-    gtk_notebook_set_scrollable(GTK_NOTEBOOK(mw.notebook), TRUE);
-    gtk_notebook_set_tab_pos(GTK_NOTEBOOK(mw.notebook), tab_pos);
-    gtk_container_add(GTK_CONTAINER(mw.win), mw.notebook);
-    g_signal_connect(G_OBJECT(mw.notebook), "switch-page",
-                     G_CALLBACK(notebook_switch_page), NULL);
+       mw.win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+       gtk_window_set_default_size(GTK_WINDOW(mw.win), 800, 600);
+       g_signal_connect(G_OBJECT(mw.win), "destroy", gtk_main_quit, NULL);
+       gtk_window_set_title(GTK_WINDOW(mw.win), __NAME__);
+
+       mw.notebook = gtk_notebook_new();
+       gtk_notebook_set_scrollable(GTK_NOTEBOOK(mw.notebook), TRUE);
+       gtk_notebook_set_tab_pos(GTK_NOTEBOOK(mw.notebook), tab_pos);
+       gtk_container_add(GTK_CONTAINER(mw.win), mw.notebook);
+       g_signal_connect(G_OBJECT(mw.notebook), "switch-page",
+                                                                        G_CALLBACK(notebook_switch_page), NULL);
 }
 
 void
 mainwindow_title(gint idx)
 {
-    GtkWidget *child, *widg, *tablabel;
-    const gchar *text;
+       GtkWidget *child, *widg, *tablabel;
+       const gchar *text;
 
-    child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(mw.notebook), idx);
-    if (child == NULL)
-        return;
+       child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(mw.notebook), idx);
+       if (child == NULL)
+               return;
 
-    widg = gtk_notebook_get_tab_label(GTK_NOTEBOOK(mw.notebook), child);
-    tablabel = (GtkWidget *)g_object_get_data(G_OBJECT(widg), "lariza-tab-label");
-    text = gtk_label_get_text(GTK_LABEL(tablabel));
-    gtk_window_set_title(GTK_WINDOW(mw.win), text);
+       widg = gtk_notebook_get_tab_label(GTK_NOTEBOOK(mw.notebook), child);
+       tablabel = (GtkWidget *)g_object_get_data(G_OBJECT(widg), "lariza-tab-label");
+       text = gtk_label_get_text(GTK_LABEL(tablabel));
+       gtk_window_set_title(GTK_WINDOW(mw.win), text);
 }
 
 void
 notebook_switch_page(GtkNotebook *nb, GtkWidget *p, guint idx, gpointer data)
 {
-    mainwindow_title(idx);
+       mainwindow_title(idx);
 }
 
 gboolean
 quit_if_nothing_active(void)
 {
-    if (clients == 0)
-    {
-        if (downloads == 0)
-        {
-            gtk_main_quit();
-            return TRUE;
-        }
-        else
-            gtk_widget_show_all(dm.win);
-    }
-
-    return FALSE;
+       if (clients == 0) {
+               if (downloads == 0) {
+                       gtk_main_quit();
+                       return TRUE;
+               } else {
+                       gtk_widget_show_all(dm.win);
+               }
+       }
+
+       return FALSE;
 }
 
 gboolean
 remote_msg(GIOChannel *channel, GIOCondition condition, gpointer data)
 {
-    gchar *uri = NULL;
-
-    g_io_channel_read_line(channel, &uri, NULL, NULL, NULL);
-    if (uri)
-    {
-        g_strstrip(uri);
-        client_new(uri, NULL, TRUE, TRUE);
-        g_free(uri);
-    }
-    return TRUE;
+       gchar *uri = NULL;
+
+       g_io_channel_read_line(channel, &uri, NULL, NULL, NULL);
+       if (uri) {
+               g_strstrip(uri);
+               client_new(uri, NULL, TRUE, TRUE);
+               g_free(uri);
+       }
+       return TRUE;
 }
 
 void
 run_user_scripts(WebKitWebView *web_view)
 {
-    gchar *base = NULL, *path = NULL, *contents = NULL;
-    const gchar *entry = NULL;
-    GDir *scriptdir = NULL;
-
-    base = g_build_filename(g_get_user_config_dir(), __NAME__, "user-scripts", NULL);
-    scriptdir = g_dir_open(base, 0, NULL);
-    if (scriptdir != NULL)
-    {
-        while ((entry = g_dir_read_name(scriptdir)) != NULL)
-        {
-            path = g_build_filename(base, entry, NULL);
-            if (g_str_has_suffix(path, ".js"))
-            {
-                if (g_file_get_contents(path, &contents, NULL, NULL))
-                {
-                    webkit_web_view_run_javascript(web_view, contents, NULL, NULL, NULL);
-                    g_free(contents);
-                }
-            }
-            g_free(path);
-        }
-        g_dir_close(scriptdir);
-    }
-
-    g_free(base);
-}
-
-void
-search(gpointer data, gint direction)
-{
-    struct Client *c = (struct Client *)data;
-    WebKitWebView *web_view = WEBKIT_WEB_VIEW(c->web_view);
-    WebKitFindController *fc = webkit_web_view_get_find_controller(web_view);
-
-    if (search_text == NULL)
-        return;
-
-    switch (direction)
-    {
-        case 0:
-            webkit_find_controller_search(fc, search_text,
-                                          WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
-                                          WEBKIT_FIND_OPTIONS_WRAP_AROUND,
-                                          G_MAXUINT);
-            break;
-        case 1:
-            webkit_find_controller_search_next(fc);
-            break;
-        case -1:
-            webkit_find_controller_search_previous(fc);
-            break;
-    }
+       gchar *base = NULL, *path = NULL, *contents = NULL;
+       const gchar *entry = NULL;
+       GDir *scriptdir = NULL;
+
+       base = g_build_filename(g_get_user_config_dir(), __NAME__, "user-scripts",
+                                                                                                       NULL);
+       scriptdir = g_dir_open(base, 0, NULL);
+       if (scriptdir != NULL) {
+               while ((entry = g_dir_read_name(scriptdir)) != NULL) {
+                       path = g_build_filename(base, entry, NULL);
+                       if (g_str_has_suffix(path, ".js")) {
+                               if (g_file_get_contents(path, &contents, NULL, NULL)) {
+                                       webkit_web_view_run_javascript(web_view, contents, NULL, NULL, NULL);
+                                       g_free(contents);
+                               }
+                       }
+                       g_free(path);
+               }
+               g_dir_close(scriptdir);
+       }
+
+       g_free(base);
 }
 
 void
 show_web_view(WebKitWebView *web_view, gpointer data)
 {
-    struct Client *c = (struct Client *)data;
-    gint idx;
+       struct Client *c = (struct Client *)data;
+       gint idx;
 
-    (void)web_view;
+       (void)web_view;
 
-    gtk_widget_show_all(mw.win);
+       gtk_widget_show_all(mw.win);
 
-    if (c->focus_new_tab)
-    {
-        idx = gtk_notebook_page_num(GTK_NOTEBOOK(mw.notebook), c->vbox);
-        if (idx != -1)
-            gtk_notebook_set_current_page(GTK_NOTEBOOK(mw.notebook), idx);
+       if (c->focus_new_tab) {
+               idx = gtk_notebook_page_num(GTK_NOTEBOOK(mw.notebook), c->vbox);
+               if (idx != -1)
+                       gtk_notebook_set_current_page(GTK_NOTEBOOK(mw.notebook), idx);
 
-        gtk_widget_grab_focus(c->web_view);
-    }
+               gtk_widget_grab_focus(c->web_view);
+       }
 }
 
 void
 trust_user_certs(WebKitWebContext *wc)
 {
-    GTlsCertificate *cert;
-    const gchar *basedir, *file, *absfile;
-    GDir *dir;
-
-    basedir = g_build_filename(g_get_user_config_dir(), __NAME__, "certs", NULL);
-    dir = g_dir_open(basedir, 0, NULL);
-    if (dir != NULL)
-    {
-        file = g_dir_read_name(dir);
-        while (file != NULL)
-        {
-            absfile = g_build_filename(g_get_user_config_dir(), __NAME__, "certs",
-                                       file, NULL);
-            cert = g_tls_certificate_new_from_file(absfile, NULL);
-            if (cert == NULL)
-                fprintf(stderr, __NAME__": Could not load trusted cert '%s'\n", file);
-            else
-                webkit_web_context_allow_tls_certificate_for_host(wc, cert, file);
-            file = g_dir_read_name(dir);
-        }
-        g_dir_close(dir);
-    }
+       GTlsCertificate *cert;
+       const gchar *basedir, *file, *absfile;
+       GDir *dir;
+
+       basedir = g_build_filename(g_get_user_config_dir(), __NAME__, "certs", NULL);
+       dir = g_dir_open(basedir, 0, NULL);
+       if (dir != NULL) {
+               file = g_dir_read_name(dir);
+               while (file != NULL) {
+                       absfile = g_build_filename(g_get_user_config_dir(), __NAME__, "certs",
+
+                                                                                                                                file, NULL);
+                       cert = g_tls_certificate_new_from_file(absfile, NULL);
+                       if (cert == NULL)
+                               fprintf(stderr, __NAME__": Could not load trusted cert '%s'\n", file);
+                       else
+                               webkit_web_context_allow_tls_certificate_for_host(wc, cert, file);
+                       file = g_dir_read_name(dir);
+               }
+               g_dir_close(dir);
+       }
 }
 
-
 int
 main(int argc, char **argv)
 {
-    int opt, i;
-
-    gtk_init(&argc, &argv);
-    grab_environment_configuration();
-
-    while ((opt = getopt(argc, argv, "C")) != -1)
-    {
-        switch (opt)
-        {
-            case 'C':
-                cooperative_instances = FALSE;
-                break;
-            default:
-                fprintf(stderr, "Usage: "__NAME__" [OPTION]... [URI]...\n");
-                exit(EXIT_FAILURE);
-        }
-    }
-
-    if (cooperative_instances)
-        cooperation_setup();
-
-    if (!cooperative_instances || cooperative_alone)
-        init_default_web_context();
-
-    downloadmanager_setup();
-    mainwindow_setup();
-
-    if (optind >= argc)
-        client_new(home_uri, NULL, TRUE, TRUE);
-    else
-    {
-        for (i = optind; i < argc; i++)
-            client_new(argv[i], NULL, TRUE, TRUE);
-    }
-
-    if (!cooperative_instances || cooperative_alone)
-        gtk_main();
-
-    exit(EXIT_SUCCESS);
+       int opt, i;
+
+       gtk_init(&argc, &argv);
+       grab_environment_configuration();
+
+       while ((opt = getopt(argc, argv, "C")) != -1) {
+               switch (opt) {
+               case 'C':
+                       cooperative_instances = FALSE;
+                       break;
+               default:
+                       fprintf(stderr, "Usage: "__NAME__" [OPTION]... [URI]...\n");
+                       exit(EXIT_FAILURE);
+               }
+       }
+
+       if (cooperative_instances)
+               cooperation_setup();
+
+       if (!cooperative_instances || cooperative_alone)
+               init_default_web_context();
+
+       downloadmanager_setup();
+       mainwindow_setup();
+
+       if (optind >= argc) {
+               client_new(home_uri, NULL, TRUE, TRUE);
+       } else {
+               for (i = optind; i < argc; i++)
+                       client_new(argv[i], NULL, TRUE, TRUE);
+       }
+
+       if (!cooperative_instances || cooperative_alone)
+               gtk_main();
+
+       exit(EXIT_SUCCESS);
 }
diff --git a/man1/lariza-usage.1 b/man1/lariza-usage.1
new file mode 100644 (file)
index 0000000..0b98375
--- /dev/null
@@ -0,0 +1,179 @@
+.TH lariza 1 "2021-01-03" "lariza" "User Commands"
+.\" --------------------------------------------------------------------
+.SH NAME
+lariza-usage \- extended usage hints
+.\" --------------------------------------------------------------------
+.SH DESCRIPTION
+\fBlariza\fP is a simple web browser using GTK+ 3, GLib and WebKit2GTK+.
+This manpage contains additional hints and pointers regarding its usage.
+.\" --------------------------------------------------------------------
+.SH "HOTKEYS"
+.SS "Global hotkeys"
+These hotkeys work when either the location bar or the web view is being
+focused.
+.TP
+\fBControl\fP + \fBq\fP
+Close the current tab. Quits the entire program if this was the last
+tab and if there are no more active downloads (download manager is
+shown otherwise).
+.TP
+\fBControl\fP + \fBw\fP
+Open a new tab.
+.TP
+\fBControl\fP + \fBe\fP
+Reload the current page.
+.TP
+\fBControl\fP + \fBy\fP
+Open the download manager.
+.TP
+\fBControl\fP + \fBd\fP
+Initiate a web search.
+.TP
+\fBControl\fP + \fBt\fP
+Focus the location bar.
+.TP
+\fBControl\fP + \fBs\fP / \fBControl\fP + \fBr\fP
+Search forwards/backwards.
+.TP
+\fBControl\fP + \fBu\fP / \fBControl\fP + \fBi\fP
+Select tab to the left / right.
+.TP
+\fBControl\fP + \fBh\fP / \fBControl\fP + \fBl\fP
+Go backward and forward in current browser history.
+.TP
+\fBControl\fP + \fB=\fP / \fBControl\fP + \fB-\fP
+Zoom in / out.
+.TP
+\fBControl\fP + \fB0\fP
+Reset zoom.
+.P
+.SS "Main window \(em WebKit viewport focused"
+.TP
+\fBEscape\fP
+Stop loading.
+.TP
+\fBMiddle mouse\fP
+Open the link under the pointer in a new window.
+.TP
+\fBBackward\fP / \fBforward\fP (mouse keys 8 and 9)
+Same as \fBF2\fP and \fBF3\fP.
+.TP
+\fBControl\fP + \fBScroll up\fP
+.TQ
+\fBCtrl\fP + \fBScroll up\fP
+Increase zoom level of the current page.
+.TP
+\fBControl\fP + \fBScroll down\fP
+.TQ
+\fBCtrl\fP + \fBScroll down\fP
+Decrase zoom level of the current page.
+.TP
+\fBControl\fP + \fBScroll horizontally\fP
+.TQ
+\fBCtrl\fP + \fBScroll horizontally\fP
+Reset zoom to $\fBLARIZA_ZOOM\fP.
+.P
+.SS "Main window \(em location bar focused"
+.TP
+\fBEscape\fP
+Reset the content of the location bar to the current URI.
+.TP
+\fBReturn\fP
+Commit, i.e. begin searching or open the URI.
+.P
+.SS "Download manager"
+.TP
+\fBControl\fP + \fBy\fP
+.TQ
+\fBControl\fP + \fBq\fP
+Close the download manager. Active downloads are never aborted. However,
+if there are no more active downloads and no more browsing windows, then
+the entire program will quit.
+.\" --------------------------------------------------------------------
+.SH "DOWNLOAD MANAGER"
+Open the download manager using the appropriate hotkey. A new window
+listing your downloads will appear. Clicking on an item will remove it
+from the list and \(em if needed \(em cancel the download.
+.P
+There's no file manager integration, nor does \fBlariza\fP delete,
+overwrite or resume downloads. If a file already exists, it won't be
+touched. Instead, the new file name will have a suffix such as \fB.1\fP,
+\fB.2\fP, \fB.3\fP, and so on.
+.\" --------------------------------------------------------------------
+.SH "USER-SUPPLIED JAVASCRIPT FILES"
+After a page has been successfully loaded, the directory
+\fI~/.config\:/lariza\:/user-scripts\fP will be scanned and each file in
+it ending with \fB.js\fP will be run as a JavaScript file in the
+context of said page.
+.P
+During development, you will most likely want to run \fBlariza\fP with
+$\fBLARIZA_ENABLE_CONSOLE_TO_STDOUT\fP enabled.
+.P
+\fBlariza\fP comes with the following scripts:
+.TP
+\fBhints.js\fP
+Press \fBf\fP (open link in current window) or \fBF\fP (open in new
+window) to activate link hints. After typing the characters for one of
+them, press \fBEnter\fP to confirm. Press \fBEscape\fP to abort.
+.TP
+\fBprivacy-redirect.js\fP
+Redirects YouTube, Reddit, etc to privacy respecting alternatives.
+.P
+Those bundled scripts are automatically installed on \fBmake install\fP.
+To use them, though, make sure to link them to the directory mentioned
+above.
+.\" --------------------------------------------------------------------
+.SH "WEB EXTENSIONS"
+On startup, WebKit checks \fI~/.config/lariza/web_extensions\fP for any
+\fB.so\fP files. See
+.UR http://\:blogs.igalia.com/\:carlosgc/\:2013/\:09/\:10/\:webkit2gtk-\:web-\:process-\:extensions/
+this blog post
+.UE
+for further information on these extensions.
+.P
+\fBlariza\fP comes with the following extensions:
+.TP
+\fBwe_adblock.so\fP
+Generic adblock. Reads patterns from the file
+\fI~/.config/lariza/adblock\fP. Each line can contain a regular
+expression. These expressions match case-insensitive and partially, i.e.
+\fB.*foo.*\fP is the same as \fB.*FOO.*\fP and you can use anchors like
+\fB^https?://...\fP. Please refer to
+.UR https://\:developer.\:gnome.\:org/\:glib/\:stable/\:glib-\:regex-\:syntax.html
+the GLib reference
+.UE
+for more details. Lines starting with \fB#\fP are ignored.
+.P
+Those bundled web extensions are automatically compiled when you run
+\fBmake\fP and installed on \fBmake install\fP. To use them, though,
+make sure to link them to the directory mentioned above.
+.\" --------------------------------------------------------------------
+.SH "TRUSTED CERTIFICATES"
+By default, \fBlariza\fP trusts whatever CAs are trusted by WebKit. If
+you wish to trust additional certificates, such as self-signed
+certificates, the first thing you should do is try to add the
+appropriate CAs to your system-wide store.
+.P
+If you wish to add simple exceptions, you can grab the certificate and
+store it in the directory \fI~/.config/lariza/certs\fP. The filename
+must be equal to the hostname:
+.P
+\f(CW
+.nf
+\&$ echo | openssl s_client -connect foo.de:443 | openssl x509 >foo.de
+.fi
+\fP
+.P
+This tells \fBlariza\fP to trust the given certificate when connecting
+to host \fBfoo.de\fP.
+.P
+You can reload these certificates at runtime by pressing the appropriate
+hotkey. Note that removed certificates will be kept in memory until you
+restart \fBlariza\fP.
+.P
+Note: This is NOT equal to certificate pinning. WebKit ignores
+user-specified certificates if the server's certificate can be validated
+by any system-wide CA.
+.\" --------------------------------------------------------------------
+.SH "SEE ALSO"
+.BR lariza (1).
index e0294dbbe37a9a3bcc1af0c6626dd30f1a4588d0..648e5ce8053c7ccb8bb058cd5516fac42fa38197 100644 (file)
@@ -84,19 +84,19 @@ Zoom level for WebKit viewports. Defaults to \fB1.0\fP.
 XDG variables will be used to construct these paths.
 .TP
 \fI~/.config\:/lariza\:/adblock\fP
-Adblock patterns. See \fBlariza.usage\fP(1).
+Adblock patterns. See \fBlariza-usage\fP(1).
 .TP
 \fI~/.config\:/lariza\:/certs\fP
 Directory where trusted certificates are stored. See
-\fBlariza.usage\fP(1).
+\fBlariza-usage\fP(1).
 .TP
-\fI~/.config\:/lariza\:/scripts\fP
+\fI~/.config\:/lariza\:/user-scripts\fP
 Directory to store user-supplied JavaScript snippets. See
-\fBlariza.usage\fP(1).
+\fBlariza-usage\fP(1).
 .TP
 \fI~/.local\:/share\:/lariza\:/web_extensions\fP
 Sets the directory where WebKit will look for web extensions. See
-\fBlariza.usage\fP(1).
+\fBlariza-usage\fP(1).
 .TP
 \fI~/.cache\:/lariza\fP
 .TQ
diff --git a/man1/lariza.usage.1 b/man1/lariza.usage.1
deleted file mode 100644 (file)
index 3682c60..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-.TH lariza 1 "2021-01-03" "lariza" "User Commands"
-.\" --------------------------------------------------------------------
-.SH NAME
-lariza.usage \- extended usage hints
-.\" --------------------------------------------------------------------
-.SH DESCRIPTION
-\fBlariza\fP is a simple web browser using GTK+ 3, GLib and WebKit2GTK+.
-This manpage contains additional hints and pointers regarding its usage.
-.\" --------------------------------------------------------------------
-.SH "HOTKEYS"
-.SS "Global hotkeys"
-These hotkeys work when either the location bar or the web view is being
-focused.
-.TP
-\fBMod1\fP + \fBq\fP
-Close the current window. Quits the entire program if this was the last
-window and if there are no more active downloads (download manager is
-shown otherwise).
-.TP
-\fBMod1\fP + \fBw\fP
-Go to your \(lqhomepage\(rq. See the environment variable
-$\fBLARIZA_HOME_URI\fP.
-.TP
-\fBMod1\fP + \fBe\fP
-Open a new window.
-.TP
-\fBMod1\fP + \fBr\fP
-Reload the current page.
-.TP
-\fBMod1\fP + \fBd\fP
-Open the download manager.
-.TP
-\fBMod1\fP + \fBl\fP
-Focus the location bar.
-.TP
-\fBMod1\fP + \fBk\fP
-Focus the location bar and set its text to \fB:/\fP, allowing you to
-easily initiate a search.
-.TP
-\fBMod1\fP + \fB2\fP
-.TQ
-\fBMod1\fP + \fBn\fP
-Repeat the last search (forward).
-.TP
-\fBMod1\fP + \fB3\fP
-Repeat the last search (backward).
-.TP
-\fBMod1\fP + \fBc\fP
-Reload trusted certificates.
-.TP
-\fBMod1\fP + \fBa\fP / \fBMod1\fP + \fBs\fP
-Select tab to the left / right.
-.TP
-\fBF2\fP / \fBF3\fP
-Go backward and forward in current browser history.
-.P
-.SS "Main window \(em WebKit viewport focused"
-.TP
-\fBEscape\fP
-Stop loading.
-.TP
-\fBMiddle mouse\fP
-Open the link under the pointer in a new window.
-.TP
-\fBBackward\fP / \fBforward\fP (mouse keys 8 and 9)
-Same as \fBF2\fP and \fBF3\fP.
-.TP
-\fBMod1\fP + \fBScroll up\fP
-.TQ
-\fBCtrl\fP + \fBScroll up\fP
-Increase zoom level of the current page.
-.TP
-\fBMod1\fP + \fBScroll down\fP
-.TQ
-\fBCtrl\fP + \fBScroll down\fP
-Decrase zoom level of the current page.
-.TP
-\fBMod1\fP + \fBScroll horizontally\fP
-.TQ
-\fBCtrl\fP + \fBScroll horizontally\fP
-Reset zoom to $\fBLARIZA_ZOOM\fP.
-.P
-.SS "Main window \(em location bar focused"
-.TP
-\fBEscape\fP
-Reset the content of the location bar to the current URI.
-.TP
-\fBReturn\fP
-Commit, i.e. begin searching or open the URI.
-.P
-.SS "Download manager"
-.TP
-\fBMod1\fP + \fBd\fP
-.TQ
-\fBMod1\fP + \fBq\fP
-Close the download manager. Active downloads are never aborted. However,
-if there are no more active downloads and no more browsing windows, then
-the entire program will quit.
-.\" --------------------------------------------------------------------
-.SH "DOWNLOAD MANAGER"
-Open the download manager using the appropriate hotkey. A new window
-listing your downloads will appear. Clicking on an item will remove it
-from the list and \(em if needed \(em cancel the download.
-.P
-There's no file manager integration, nor does \fBlariza\fP delete,
-overwrite or resume downloads. If a file already exists, it won't be
-touched. Instead, the new file name will have a suffix such as \fB.1\fP,
-\fB.2\fP, \fB.3\fP, and so on.
-.\" --------------------------------------------------------------------
-.SH "USER-SUPPLIED JAVASCRIPT FILES"
-After a page has been successfully loaded, the directory
-\fI~/.config\:/lariza\:/user-scripts\fP will be scanned and each file in
-it ending with \fB.js\fP will be run as a JavaScript file in the context
-of said page.
-.P
-During development, you will most likely want to run \fBlariza\fP with
-$\fBLARIZA_ENABLE_CONSOLE_TO_STDOUT\fP enabled.
-.P
-\fBlariza\fP comes with the following scripts:
-.TP
-\fBhints.js\fP
-Press \fBf\fP (open link in current window) or \fBF\fP (open in new
-window) to activate link hints. After typing the characters for one of
-them, press \fBEnter\fP to confirm. Press \fBEscape\fP to abort.
-.P
-Those bundled scripts are automatically installed on \fBmake install\fP.
-To use them, though, make sure to link them to the directory mentioned
-above.
-.\" --------------------------------------------------------------------
-.SH "WEB EXTENSIONS"
-On startup, WebKit checks \fI~/.config/lariza/web_extensions\fP for any
-\fB.so\fP files. See
-.UR http://\:blogs.igalia.com/\:carlosgc/\:2013/\:09/\:10/\:webkit2gtk-\:web-\:process-\:extensions/
-this blog post
-.UE
-for further information on these extensions.
-.P
-\fBlariza\fP comes with the following extensions:
-.TP
-\fBwe_adblock.so\fP
-Generic adblock. Reads patterns from the file
-\fI~/.config/lariza/adblock\fP. Each line can contain a regular
-expression. These expressions match case-insensitive and partially, i.e.
-\fB.*foo.*\fP is the same as \fB.*FOO.*\fP and you can use anchors like
-\fB^https?://...\fP. Please refer to
-.UR https://\:developer.\:gnome.\:org/\:glib/\:stable/\:glib-\:regex-\:syntax.html
-the GLib reference
-.UE
-for more details. Lines starting with \fB#\fP are ignored.
-.P
-Those bundled web extensions are automatically compiled when you run
-\fBmake\fP and installed on \fBmake install\fP. To use them, though,
-make sure to link them to the directory mentioned above.
-.\" --------------------------------------------------------------------
-.SH "TRUSTED CERTIFICATES"
-By default, \fBlariza\fP trusts whatever CAs are trusted by WebKit. If
-you wish to trust additional certificates, such as self-signed
-certificates, the first thing you should do is try to add the
-appropriate CAs to your system-wide store.
-.P
-If you wish to add simple exceptions, you can grab the certificate and
-store it in the directory \fI~/.config/lariza/certs\fP. The filename
-must be equal to the hostname:
-.P
-\f(CW
-.nf
-\&$ echo | openssl s_client -connect foo.de:443 | openssl x509 >foo.de
-.fi
-\fP
-.P
-This tells \fBlariza\fP to trust the given certificate when connecting
-to host \fBfoo.de\fP.
-.P
-You can reload these certificates at runtime by pressing the appropriate
-hotkey. Note that removed certificates will be kept in memory until you
-restart \fBlariza\fP.
-.P
-Note: This is NOT equal to certificate pinning. WebKit ignores
-user-specified certificates if the server's certificate can be validated
-by any system-wide CA.
-.\" --------------------------------------------------------------------
-.SH "SEE ALSO"
-.BR lariza (1).
diff --git a/user-scripts/privacy-redirect.js b/user-scripts/privacy-redirect.js
new file mode 100644 (file)
index 0000000..cbcd9a2
--- /dev/null
@@ -0,0 +1,53 @@
+/* Targets taken from the privacy-redirect webextension
+        This isn't great, as it does still load the webpage before
+        redirecting, however it is better than nothing. */
+
+const youtube_targets = [
+               "m.youtube.com",
+               "youtube.com",
+               "img.youtube.com",
+               "www.youtube.com",
+               "youtube-nocookie.com",
+               "www.youtube-nocookie.com",
+               "youtu.be",
+               "s.ytimg.com",
+               "music.youtube.com",
+];
+
+const twitter_targets = [
+               "twitter.com",
+               "www.twitter.com",
+               "mobile.twitter.com",
+               "pbs.twimg.com",
+               "video.twimg.com",
+];
+
+const reddit_targets = [
+               "reddit.com",
+               "www.reddit.com",
+               "np.reddit.com",
+               "new.reddit.com",
+               "amp.reddit.com",
+               "i.redd.it",
+];
+
+const instagram_targets = [
+               "instagram.com",
+               "www.instagram.com",
+               "help.instagram.com",
+               "about.instagram.com",
+];
+
+const targets = [
+               [youtube_targets, "https://invidious.fdn.fr"],
+               [twitter_targets, "https://nitter.fdn.fr"],
+               [reddit_targets, "https://teddit.net"],
+               [instagram_targets, "https://insta.trom.tf"],
+];
+
+for (i = 0; i < targets.length; i++) {
+               if (targets[i][0].indexOf(window.location.hostname) > -1) {
+                               document.write('<script type="text/undefined">')
+                               location.replace(targets[i][1] + window.location.pathname);
+               }
+}