1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-15 23:35:34 +00:00

[clipboard] Added "ui.clipboard_file" to add text to the system clipboard.

ui.clipboard_file is filename of the clipboard file. This file can be a named pipe.
See contrib/clipboard/clip.sh how to set up copying to clipboard using socat and xclip.
Just run clip.sh (it will be running in a loop) before starting elinks and
set ui.clipboard_file = "~/.elinks/clipboard.fifo".
This commit is contained in:
Witold Filipczyk 2020-07-27 22:38:54 +02:00
parent 073bad0776
commit 911155a862
3 changed files with 34 additions and 0 deletions

8
contrib/clipboard/clip.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
trap exit SIGTERM SIGINT
while true
do
socat -u PIPE:$HOME/.elinks/clipboard.fifo EXEC:"xclip -sel clip"
done

View File

@ -1459,6 +1459,10 @@ static union option_info config_options_info[] = {
N_("Keep the session active even if the last terminal "
"exits.")),
INIT_OPT_STRING("ui", N_("Clipboard file"),
"clipboard_file", 0, "",
N_("Filename of the clipboard file.")),
#ifdef HAVE_STRFTIME
INIT_OPT_STRING("ui", N_("Date format"),
"date_format", 0, "%b %e %H:%M",

View File

@ -67,11 +67,13 @@
#include "elinks.h"
#include "config/options.h"
#include "main/select.h"
#include "osdep/osdep.h"
#include "osdep/signals.h"
#include "terminal/terminal.h"
#include "util/conv.h"
#include "util/file.h"
#include "util/memory.h"
#include "util/string.h"
@ -403,6 +405,26 @@ get_clipboard_text(void)
void
set_clipboard_text(unsigned char *data)
{
unsigned char *f = get_opt_str("ui.clipboard_file", NULL);
if (f && *f) {
unsigned char *filename = expand_tilde(f);
if (filename) {
#ifdef HAVE_ACCESS
if (access(filename, W_OK) >= 0) {
FILE *out = fopen(filename, "a");
if (out) {
fputs(data, out);
fclose(out);
}
}
#endif
mem_free(filename);
}
}
/* GNU Screen's clipboard */
if (is_gnuscreen()) {
struct string str;