diff options
| author | auric <auric7@protonmail.com> | 2025-09-07 20:17:07 -0500 |
|---|---|---|
| committer | auric <auric7@protonmail.com> | 2025-09-07 20:17:07 -0500 |
| commit | 22d02614eaa4530092d564336b3e7076c9f0bc36 (patch) | |
| tree | 947fd56ed33fedb80c14dab7adab0dc71760540b /oldresources/st/patch/opencopied.c | |
| parent | 7de2c2044596ef810045e4565916e18903d822c1 (diff) | |
1
Diffstat (limited to 'oldresources/st/patch/opencopied.c')
| -rw-r--r-- | oldresources/st/patch/opencopied.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/oldresources/st/patch/opencopied.c b/oldresources/st/patch/opencopied.c new file mode 100644 index 0000000..9b07c58 --- /dev/null +++ b/oldresources/st/patch/opencopied.c @@ -0,0 +1,19 @@ +void +opencopied(const Arg *arg) +{ + int res; + 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); + res = system(cmd); +}
\ No newline at end of file |
