Add mouse function to play medias in external player

Control + left click launches mpv with the target media url.
This commit is contained in:
Quentin Rameau 2015-11-21 19:53:29 +01:00
parent 26eb2f761c
commit 954a718197
2 changed files with 20 additions and 0 deletions

View File

@ -65,6 +65,13 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
} \ } \
} }
/* VIDEOPLAY(URI) */
#define VIDEOPLAY(u) {\
.v = (const char *[]){ "/bin/sh", "-c", \
"mpv --really-quiet \"$0\"", u, NULL \
} \
}
/* styles */ /* styles */
/* /*
* The iteration will stop at the first match, beginning at the beginning of * The iteration will stop at the first match, beginning at the beginning of
@ -142,4 +149,5 @@ static Button buttons[] = {
{ OnLink, MODKEY, 1, clicknewwindow, { .b = 1 }, 1 }, { OnLink, MODKEY, 1, clicknewwindow, { .b = 1 }, 1 },
{ OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 }, { OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 },
{ OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 }, { OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 },
{ OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 },
}; };

12
surf.c
View File

@ -178,6 +178,7 @@ static void find(Client *c, const Arg *a);
/* Buttons */ /* Buttons */
static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h); static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h);
static void clicknewwindow(Client *c, const Arg *a, WebKitHitTestResult *h); static void clicknewwindow(Client *c, const Arg *a, WebKitHitTestResult *h);
static void clickexternplayer(Client *c, const Arg *a, WebKitHitTestResult *h);
static char winid[64]; static char winid[64];
static char togglestats[10]; static char togglestats[10];
@ -1462,6 +1463,17 @@ clicknewwindow(Client *c, const Arg *a, WebKitHitTestResult *h)
newwindow(c, &arg, a->b); newwindow(c, &arg, a->b);
} }
void
clickexternplayer(Client *c, const Arg *a, WebKitHitTestResult *h)
{
Arg arg;
if (webkit_hit_test_result_get_context(h) & OnMedia) {
arg = (Arg)VIDEOPLAY(webkit_hit_test_result_get_media_uri(h));
spawn(c, &arg);
}
}
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {