# st

Unnamed repository; edit this file 'description' to name the repository.

| Log | Files | Refs | README | LICENSE

    commit aff94637b48d260c98216424664b1aee0ad75213
    parent 21cdbf21172e9c509560fb5c5e5528412cf5efdd
    Author: c0dev0id <sh+github@codevoid.de>
    Date:   Sat, 31 Jul 2021 19:58:13 +0200

    sdk-openurl

    Diffstat:
    Mconfig.def.h | 1+
    Mconfig.h | 1+
    Mst.h | 1+
    Mx.c | 19+++++++++++++++++++

    4 files changed, 22 insertions(+), 0 deletions(-)
    diff --git a/config.def.h b/config.def.h
    @@ -214,6 +214,7 @@ static Shortcut shortcuts[] = {
     	{ ShiftMask,            XK_Page_Up,     kscrollup,      {.i = -1} },
     	{ ShiftMask,            XK_Page_Down,   kscrolldown,    {.i = -1} },
     	{ ShiftMask,            XK_l,           copyurl,        {.i =  0} },
    +	{ ShiftMask,            XK_o,           opencopied,     {.v = "luakit"} },
     };

     /*
    diff --git a/config.h b/config.h
    @@ -214,6 +214,7 @@ static Shortcut shortcuts[] = {
     	{ ShiftMask,            XK_Page_Up,     kscrollup,      {.i = -1} },
     	{ ShiftMask,            XK_Page_Down,   kscrolldown,    {.i = -1} },
     	{ ShiftMask,            XK_l,           copyurl,        {.i =  0} },
    +	{ ShiftMask,            XK_o,           opencopied,     {.v = "luakit"} },
     };

     /*
    diff --git a/st.h b/st.h
    @@ -84,6 +84,7 @@ void draw(void);

     void kscrolldown(const Arg *);
     void kscrollup(const Arg *);
    +void opencopied(const Arg *);
     void printscreen(const Arg *);
     void printsel(const Arg *);
     void sendbreak(const Arg *);
    diff --git a/x.c b/x.c
    @@ -2078,3 +2078,22 @@ run:

     	return 0;
     }
    +
    +void
    +opencopied(const Arg *arg)
    +{
    +	size_t const max_cmd = 2048;
    +	char * const clip = xsel.clipboard;
    +	if(!clip) {
    +		fprintf(stderr, "Warning: nothing copied to clipboard\n");
    +		return;
    +	}
    +
    +	/* account for space/quote (3) and \0 (1) and & (1) */
    +	/* e.g.: xdg-open "https://st.suckless.org"& */
    +	size_t const cmd_size = max_cmd + strlen(clip) + 5;
    +	char cmd[cmd_size];
    +
    +	snprintf(cmd, cmd_size, "%s \"%s\"&", (char *)arg->v, clip);
    +	system(cmd);
    +}