[wiki] [sites] [surf][patch][notifications] surf: add patch for html5 notifications || Erno Hopearuoho

From: <git_AT_suckless.org>
Date: Thu, 04 Jun 2020 16:54:06 +0200

commit dc8bd43967a282eb82153e7175c45467fcf03698
Author: Erno Hopearuoho <erno.hopearuoho_AT_gmail.com>
Date: Thu Jun 4 17:51:19 2020 +0300

    [surf][patch][notifications] surf: add patch for html5 notifications

diff --git a/surf.suckless.org/patches/notifications/index.md b/surf.suckless.org/patches/notifications/index.md
new file mode 100644
index 00000000..b37a161f
--- /dev/null
+++ b/surf.suckless.org/patches/notifications/index.md
_AT_@ -0,0 +1,19 @@
+notifications
+=============
+
+Description
+-----------
+
+Adds support for HTML5 Web Notifications
+
+Enable by either passing **-L** parameter or by pressing **Ctrl-Shift-L** on the window.
+
+Download
+--------
+
+* [surf-2.0-notifications.diff](surf-2.0-notifications.diff) (3.0k) (20200604)
+
+Author
+------
+
+* Erno Hopearuoho - erno.hopearuoho_AT_gmail.com
diff --git a/surf.suckless.org/patches/notifications/surf-2.0-notifications.diff b/surf.suckless.org/patches/notifications/surf-2.0-notifications.diff
new file mode 100644
index 00000000..3c5c8654
--- /dev/null
+++ b/surf.suckless.org/patches/notifications/surf-2.0-notifications.diff
_AT_@ -0,0 +1,88 @@
+diff --git a/config.def.h b/config.def.h
+index 6d3135e..2b3a14f 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -22,6 +22,7 @@ static Parameter defconfig[ParameterLast] = {
+ SETB(KioskMode, 0),
+ SETB(LoadImages, 1),
+ SETB(MediaManualPlay, 0),
++ SETB(Notifications, 0),
+ SETB(Plugins, 1),
+ SETV(PreferredLanguages, ((char *[]){ NULL })),
+ SETB(RunInFullscreen, 0),
+_AT_@ -148,6 +149,7 @@ static Key keys[] = {
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, toggle, { .i = Geolocation } },
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript } },
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages } },
++ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_l, toggle, { .i = Notifications } },
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_v, toggle, { .i = Plugins } },
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } },
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } },
+diff --git a/surf.c b/surf.c
+index 93a1629..d47dc60 100644
+--- a/surf.c
++++ b/surf.c
+_AT_@ -72,6 +72,7 @@ typedef enum {
+ KioskMode,
+ LoadImages,
+ MediaManualPlay,
++ Notifications,
+ Plugins,
+ PreferredLanguages,
+ RunInFullscreen,
+_AT_@ -568,7 +569,8 @@ gettogglestats(Client *c)
+ togglestats[6] = curconfig[Plugins].val.b ? 'V' : 'v';
+ togglestats[7] = curconfig[Style].val.b ? 'M' : 'm';
+ togglestats[8] = curconfig[FrameFlattening].val.b ? 'F' : 'f';
+- togglestats[9] = '++ togglestats[9] = curconfig[Notifications].val.b ? 'L' : 'l';
++ togglestats[10] = '+ }
+
+ void
+_AT_@ -681,6 +683,9 @@ setparameter(Client *c, int refresh, ParamName p, const Arg *a)
+ case MediaManualPlay:
+ webkit_settings_set_media_playback_requires_user_gesture(s, a->b);
+ break;
++ case Notifications:
++ refresh = 0;
++ return;
+ case Plugins:
+ webkit_settings_set_enable_plugins(s, a->b);
+ break;
+_AT_@ -834,6 +839,7 @@ newwindow(Client *c, const Arg *a, int noembed)
+ cmd[i++] = curconfig[Geolocation].val.b ? "-G" : "-g" ;
+ cmd[i++] = curconfig[LoadImages].val.b ? "-I" : "-i" ;
+ cmd[i++] = curconfig[KioskMode].val.b ? "-K" : "-k" ;
++ cmd[i++] = curconfig[Notifications].val.b ? "-L" : "-l" ;
+ cmd[i++] = curconfig[Style].val.b ? "-M" : "-m" ;
+ cmd[i++] = curconfig[Inspector].val.b ? "-N" : "-n" ;
+ cmd[i++] = curconfig[Plugins].val.b ? "-P" : "-p" ;
+_AT_@ -1301,6 +1307,14 @@ permissionrequested(WebKitWebView *v, WebKitPermissionRequest *r, Client *c)
+ return TRUE;
+ }
+
++ if (WEBKIT_IS_NOTIFICATION_PERMISSION_REQUEST(r)) {
++ if (curconfig[Notifications].val.b)
++ webkit_permission_request_allow(r);
++ else
++ webkit_permission_request_deny(r);
++ return TRUE;
++ }
++
+ return FALSE;
+ }
+
+_AT_@ -1703,6 +1717,12 @@ main(int argc, char *argv[])
+ case 'K':
+ defconfig CSETB(KioskMode, 1);
+ break;
++ case 'l':
++ defconfig CSETB(Notifications, 0);
++ break;
++ case 'L':
++ defconfig CSETB(Notifications, 1);
++ break;
+ case 'm':
+ defconfig CSETB(Style, 0);
+ break;
Received on Thu Jun 04 2020 - 16:54:06 CEST

This archive was generated by hypermail 2.3.0 : Thu Jun 04 2020 - 17:00:45 CEST