[wiki] [sites] [st custom patch] Add ability to open clipboard with configured browser || Michael Buch
commit a0246a57cfe16ec7fbf7f877b8fbb8851aea5e24
Author: Michael Buch <michaelbuch12_AT_gmail.com>
Date: Fri May 25 01:49:19 2018 +0100
[st custom patch] Add ability to open clipboard with configured browser
Lets user define a program to run (in config.h) and uses contents
of CLIPBOARD selection to pass as a parameter. This can be bound
to any key. By default binds Mod+o to opening the default
browser.
diff --git a/st.suckless.org/patches/open_copied_url/index.md b/st.suckless.org/patches/open_copied_url/index.md
new file mode 100644
index 00000000..f4a2b980
--- /dev/null
+++ b/st.suckless.org/patches/open_copied_url/index.md
_AT_@ -0,0 +1,35 @@
+open_copied_url
+=======
+
+Description
+-----------
+
+Open contents of the clipboard in a user-defined browser.
+
+The clipboard in this case refers to the CLIPBOARD selection which gets
+populated when pressing e.g. C-c.
+
+Instructions
+-----------
+
+Add a keybinding like the following example to "shortcuts" in config.h:
+
+ { MODKEY, XK_v, opencopied, {.v = "firefox"} },
+
+Set the .v field of the last parameter to the program you want to bind to the key.
+
+Notes
+-----
+
+By default this patch binds the Mod+o to "xdg-open". This allows users
+to open the contents of the clipboard in the default browser.
+
+Download
+--------
+
+ * [st-openclipboard-20180525-2c2500c.diff](st-openclipboard-20180525-2c2500c.diff)
+
+Authors
+-------
+
+ * Michael Buch - <michaelbuch12_AT_gmail.com>
diff --git a/st.suckless.org/patches/open_copied_url/st-openclipboard-20180525-2c2500c.diff b/st.suckless.org/patches/open_copied_url/st-openclipboard-20180525-2c2500c.diff
new file mode 100644
index 00000000..88aea1e4
--- /dev/null
+++ b/st.suckless.org/patches/open_copied_url/st-openclipboard-20180525-2c2500c.diff
_AT_@ -0,0 +1,73 @@
+From 2c2500c057433148c49465b9d009193ffcef6432 Mon Sep 17 00:00:00 2001
+From: Michael Buch <michaelbuch12_AT_gmail.com>
+Date: Fri, 25 May 2018 00:02:40 +0100
+Subject: [PATCH] [st patch] Add ability to open clipboard with configured
+ program
+
+Lets user define a program to run in config.h and uses contents
+of CLIPBOARD selection to pass as a parameter. This can be bound
+to any key. By default binds Mod+o to opening the default
+browser.
+---
+ config.def.h | 1 +
+ st.h | 1 +
+ x.c | 22 ++++++++++++++++++++++
+ 3 files changed, 24 insertions(+)
+
+diff --git a/config.def.h b/config.def.h
+index 82b1b09..83627db 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -178,6 +178,7 @@ static Shortcut shortcuts[] = {
+ { TERMMOD, XK_Y, selpaste, {.i = 0} },
+ { TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
+ { TERMMOD, XK_I, iso14755, {.i = 0} },
++ { MODKEY, XK_o, opencopied, {.v = "xdg-open"} },
+ };
+
+ /*
+diff --git a/st.h b/st.h
+index dac64d8..773eeb3 100644
+--- a/st.h
++++ b/st.h
+_AT_@ -81,6 +81,7 @@ void redraw(void);
+ void draw(void);
+
+ void iso14755(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
+index c0bd890..b7edc5e 100644
+--- a/x.c
++++ b/x.c
+_AT_@ -1949,3 +1949,25 @@ run:
+
+ return 0;
+ }
++
++void
++opencopied(const Arg *arg)
++{
++ const size_t max_cmd = 2048;
++ const char *clip = xsel.clipboard;
++ if(!clip) {
++ fprintf(stderr, "Warning: nothing copied to clipboard
");
++ return;
++ }
++
++ /* account for space/quote (3) and
Received on Fri May 25 2018 - 02:49:52 CEST
This archive was generated by hypermail 2.3.0
: Fri May 25 2018 - 03:00:24 CEST