diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e474bc2a6..000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "lib/clip"] - path = lib/clip - url = https://github.com/dacap/clip.git diff --git a/Makefile b/Makefile index 516291592..064397e8c 100644 --- a/Makefile +++ b/Makefile @@ -115,13 +115,6 @@ ifeq ($(THREADS),1) override THREADS := auto endif -#? Pull in the clipboard library -CLIPDIR := lib/clip -override ADDFLAGS += -L$(CLIPDIR) -lclip -ifeq ($(PLATFORM_LC),linux) - override ADDFLAGS += -lxcb -endif - #? The Directories, Source, Includes, Objects and Binary SRCDIR := src INCDIR := include @@ -141,7 +134,7 @@ OPTFLAGS := -O2 -ftree-vectorize -flto=$(THREADS) LDCXXFLAGS := -pthread -D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS $(GOODFLAGS) $(ADDFLAGS) override CXXFLAGS += $(REQFLAGS) $(LDCXXFLAGS) $(OPTFLAGS) $(WARNFLAGS) override LDFLAGS += $(LDCXXFLAGS) $(OPTFLAGS) $(WARNFLAGS) -INC := -I$(INCDIR) -I$(CLIPDIR) -I$(SRCDIR) +INC := -I$(INCDIR) -I$(SRCDIR) SU_USER := root ifdef DEBUG @@ -175,11 +168,6 @@ P := %% #? Default Make all: $(PRE) directories btop -clip: - @cd $(CLIPDIR) - @env CXXFLAGS="" LDFLAGS="" cmake -DCLIP_X11_WITH_PNG=OFF . - @env CXXFLAGS="" LDFLAGS="" make - info: @printf " $(BANNER)\n" @printf "\033[1;92mPLATFORM \033[1;93m?| \033[0m$(PLATFORM)\n" @@ -273,7 +261,7 @@ uninstall: #? Link .ONESHELL: -btop: $(OBJECTS) | directories clip +btop: $(OBJECTS) | directories @sleep 0.2 2>/dev/null || true @TSTAMP=$$(date +%s 2>/dev/null || echo "0") @$(QUIET) || printf "\n\033[1;92mLinking and optimizing binary\033[37m...\033[0m\n" diff --git a/lib/clip b/lib/clip deleted file mode 160000 index 3433235c7..000000000 --- a/lib/clip +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3433235c7faa86d28507558cf07ffa0d933ffd72 diff --git a/src/btop_config.cpp b/src/btop_config.cpp index 8afa1cbe0..1743b673a 100644 --- a/src/btop_config.cpp +++ b/src/btop_config.cpp @@ -62,6 +62,8 @@ namespace Config { {"vim_keys", "#* Set to True to enable \"h,j,k,l,g,G\" keys for directional control in lists.\n" "#* Conflicting keys for h:\"help\" and k:\"kill\" is accessible while holding shift."}, + {"copy_command", "#* Command to copy to the system clipboard. Clipboard contents are piped into stdin."}, + {"rounded_corners", "#* Rounded corners on boxes, is ignored if TTY mode is ON."}, {"graph_symbol", "#* Default symbols to use for graph creation, \"braille\", \"block\" or \"tty\".\n" @@ -198,6 +200,7 @@ namespace Config { {"shown_boxes", "cpu mem net proc"}, {"graph_symbol", "braille"}, {"presets", "cpu:1:default,proc:0:default cpu:0:default,mem:0:default,net:0:default cpu:0:block,net:0:tty"}, + {"copy_command", ""}, {"graph_symbol_cpu", "default"}, {"graph_symbol_mem", "default"}, {"graph_symbol_net", "default"}, diff --git a/src/btop_input.cpp b/src/btop_input.cpp index 02dcf21b0..1000540e6 100644 --- a/src/btop_input.cpp +++ b/src/btop_input.cpp @@ -22,8 +22,6 @@ tab-size = 4 #include #include -#include - #include #include #include @@ -441,7 +439,19 @@ namespace Input { } else if (key == "x") { atomic_wait(Runner::active); - clip::set_text(Config::getS("selected_cmd")); + + auto copy_command = Config::getS("copy_command"); + if (copy_command.empty()) { + vector cont_vec; + cont_vec.emplace_back("`copy_command` is empty"); + Menu::msgBox messageBox = Menu::msgBox{45, 0, cont_vec, "error"}; + Global::overlay = messageBox(); + } else { + FILE *p_copy_stdin = popen(copy_command.c_str(), "w"); + auto selected_cmd = Config::getS("selected_cmd"); + fwrite(selected_cmd.c_str(), selected_cmd.length(), selected_cmd.length(), p_copy_stdin); + pclose(p_copy_stdin); + } } else keep_going = true;