[wiki] [sites] [st][patch][open_copied_url] Add exec promise to pledge || c0dev0id

From: <git_AT_suckless.org>
Date: Mon, 02 Aug 2021 19:10:48 +0200

commit a30f1e4947c67cfdde4aa094d45b54c571ef74c5
Author: c0dev0id <sh+github_AT_codevoid.de>
Date: Mon Aug 2 19:07:30 2021 +0200

    [st][patch][open_copied_url] Add exec promise to pledge
    
    The open copied url patch executes a launcher or browser.
    It can't do that on openbsd when the pledge promose exec is not given.

diff --git a/st.suckless.org/patches/open_copied_url/index.md b/st.suckless.org/patches/open_copied_url/index.md
index 2447ed66..d2513c1c 100644
--- a/st.suckless.org/patches/open_copied_url/index.md
+++ b/st.suckless.org/patches/open_copied_url/index.md
_AT_@ -25,6 +25,7 @@ Download
 --------
 * [st-openclipboard-20190202-0.8.1.diff](st-openclipboard-20190202-0.8.1.diff)
 * [st-openclipboard-20190202-3be4cf1.diff](st-openclipboard-20190202-3be4cf1.diff)
+* [st-openclipboard-20210802-2ec571.diff](st-openclipboard-20210802-2ec571.diff)
 
 Authors
 -------
diff --git a/st.suckless.org/patches/open_copied_url/st-openclipboard-20210802-2ec571.diff b/st.suckless.org/patches/open_copied_url/st-openclipboard-20210802-2ec571.diff
new file mode 100644
index 00000000..83481480
--- /dev/null
+++ b/st.suckless.org/patches/open_copied_url/st-openclipboard-20210802-2ec571.diff
_AT_@ -0,0 +1,83 @@
+From 500caedd35e028a1243f4b24c8b7a364c9992f07 Mon Sep 17 00:00:00 2001
+From: c0dev0id <sh+github_AT_codevoid.de>
+Date: Mon, 2 Aug 2021 18:52:54 +0200
+Subject: [PATCH] Update open copied url for pledge
+
+Since st was pledged, the copy open url patch did not work anymore
+because it does something (exec) pledge did not allow. This patch adds
+the exec promise to pledge.
+
+---
+ config.def.h | 1 +
+ st.c | 2 +-
+ st.h | 1 +
+ x.c | 19 +++++++++++++++++++
+ 4 files changed, 22 insertions(+), 1 deletion(-)
+
+diff --git a/config.def.h b/config.def.h
+index 6f05dce..2b1c39b 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -199,6 +199,7 @@ static Shortcut shortcuts[] = {
+ { TERMMOD, XK_Y, selpaste, {.i = 0} },
+ { ShiftMask, XK_Insert, selpaste, {.i = 0} },
+ { TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
++ { MODKEY, XK_o, opencopied, {.v = "xdg-open"} },
+ };
+
+ /*
+diff --git a/st.c b/st.c
+index ebdf360..d18db82 100644
+--- a/st.c
++++ b/st.c
+_AT_@ -809,7 +809,7 @@ ttynew(const char *line, char *cmd, const char *out, char **args)
+ break;
+ default:
+ #ifdef __OpenBSD__
+- if (pledge("stdio rpath tty proc", NULL) == -1)
++ if (pledge("stdio rpath tty proc exec", NULL) == -1)
+ die("pledge
");
+ #endif
+ close(s);
+diff --git a/st.h b/st.h
+index fa2eddf..2a377cb 100644
+--- a/st.h
++++ b/st.h
+_AT_@ -81,6 +81,7 @@ void die(const char *, ...);
+ void redraw(void);
+ void draw(void);
+
++void opencopied(const Arg *);
+ void printscreen(const Arg *);
+ void printsel(const Arg *);
+ void sendbreak(const Arg *);
+diff --git a/x.c b/x.c
+index 248d505..5a4bd81 100644
+--- a/x.c
++++ b/x.c
+_AT_@ -2063,3 +2063,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
");
++ return;
++ }
++
++ /* account for space/quote (3) and ++ /* 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);
++}
+--
+2.32.0
+
Received on Mon Aug 02 2021 - 19:10:48 CEST

This archive was generated by hypermail 2.3.0 : Mon Aug 02 2021 - 19:12:44 CEST