st-flexipatch

My st-flexipatch configuration
git clone git://git.ethandl.dev/st-flexipatch
Log | Files | Refs | README | LICENSE

opencopied.c (463B)


      1 void
      2 opencopied(const Arg *arg)
      3 {
      4 	int res;
      5 	size_t const max_cmd = 2048;
      6 	char * const clip = xsel.clipboard;
      7 	if (!clip) {
      8 		fprintf(stderr, "Warning: nothing copied to clipboard\n");
      9 		return;
     10 	}
     11 
     12 	/* account for space/quote (3) and \0 (1) and & (1) */
     13 	/* e.g.: xdg-open "https://st.suckless.org"& */
     14 	size_t const cmd_size = max_cmd + strlen(clip) + 5;
     15 	char cmd[cmd_size];
     16 
     17 	snprintf(cmd, cmd_size, "%s \"%s\"&", (char *)arg->v, clip);
     18 	res = system(cmd);
     19 }