Introduction
Introduction Statistics Contact Development Disclaimer Help
st-openclipboard-20210802-2ec571.diff - sites - public wiki contents of suckles…
git clone git://git.suckless.org/sites
Log
Files
Refs
---
st-openclipboard-20210802-2ec571.diff (2220B)
---
1 From 500caedd35e028a1243f4b24c8b7a364c9992f07 Mon Sep 17 00:00:00 2001
2 From: c0dev0id <[email protected]>
3 Date: Mon, 2 Aug 2021 18:52:54 +0200
4 Subject: [PATCH] Update open copied url for pledge
5
6 Since st was pledged, the copy open url patch did not work anymore
7 because it does something (exec) pledge did not allow. This patch adds
8 the exec promise to pledge.
9
10 ---
11 config.def.h | 1 +
12 st.c | 2 +-
13 st.h | 1 +
14 x.c | 19 +++++++++++++++++++
15 4 files changed, 22 insertions(+), 1 deletion(-)
16
17 diff --git a/config.def.h b/config.def.h
18 index 6f05dce..2b1c39b 100644
19 --- a/config.def.h
20 +++ b/config.def.h
21 @@ -199,6 +199,7 @@ static Shortcut shortcuts[] = {
22 { TERMMOD, XK_Y, selpaste, {.i = …
23 { ShiftMask, XK_Insert, selpaste, {.i = …
24 { TERMMOD, XK_Num_Lock, numlock, {.i = …
25 + { MODKEY, XK_o, opencopied, {.v = "…
26 };
27
28 /*
29 diff --git a/st.c b/st.c
30 index ebdf360..d18db82 100644
31 --- a/st.c
32 +++ b/st.c
33 @@ -809,7 +809,7 @@ ttynew(const char *line, char *cmd, const char *out,…
34 break;
35 default:
36 #ifdef __OpenBSD__
37 - if (pledge("stdio rpath tty proc", NULL) == -1)
38 + if (pledge("stdio rpath tty proc exec", NULL) == -1)
39 die("pledge\n");
40 #endif
41 close(s);
42 diff --git a/st.h b/st.h
43 index fa2eddf..2a377cb 100644
44 --- a/st.h
45 +++ b/st.h
46 @@ -81,6 +81,7 @@ void die(const char *, ...);
47 void redraw(void);
48 void draw(void);
49
50 +void opencopied(const Arg *);
51 void printscreen(const Arg *);
52 void printsel(const Arg *);
53 void sendbreak(const Arg *);
54 diff --git a/x.c b/x.c
55 index 248d505..5a4bd81 100644
56 --- a/x.c
57 +++ b/x.c
58 @@ -2063,3 +2063,22 @@ run:
59
60 return 0;
61 }
62 +
63 +void
64 +opencopied(const Arg *arg)
65 +{
66 + size_t const max_cmd = 2048;
67 + char * const clip = xsel.clipboard;
68 + if(!clip) {
69 + fprintf(stderr, "Warning: nothing copied to clipboard\n…
70 + return;
71 + }
72 +
73 + /* account for space/quote (3) and \0 (1) and & (1) */
74 + /* e.g.: xdg-open "https://st.suckless.org"& */
75 + size_t const cmd_size = max_cmd + strlen(clip) + 5;
76 + char cmd[cmd_size];
77 +
78 + snprintf(cmd, cmd_size, "%s \"%s\"&", (char *)arg->v, clip);
79 + system(cmd);
80 +}
81 --
82 2.32.0
83
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.