From b071e17eccbf599af4dff42fa757e453a01fed97 Mon Sep 17 00:00:00 2001 From: Scott Little Date: Fri, 23 Apr 2021 14:02:41 -0500 Subject: [PATCH 1/4] Add support for wl-copy/Wayland --- share/cht.sh.txt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/share/cht.sh.txt b/share/cht.sh.txt index c49ca7b..3b7f125 100755 --- a/share/cht.sh.txt +++ b/share/cht.sh.txt @@ -514,7 +514,11 @@ else fi if [ "$is_macos" != yes ]; then - command -v xsel >/dev/null || echo 'DEPENDENCY: please install "xsel" for "copy"' >&2 + if [ "$XDG_SESSION_TYPE" = wayland ]; then + command -v wl-copy >/dev/null || echo 'DEPENDENCY: please install "wl-copy" for "copy"' >&2 + else + command -v xsel >/dev/null || echo 'DEPENDENCY: please install "xsel" for "copy"' >&2 + fi fi command -v rlwrap >/dev/null || { echo 'DEPENDENCY: install "rlwrap" to use cht.sh in the shell mode' >&2; exit 1; } @@ -562,7 +566,11 @@ cmd_copy() { else curl -s "${CHTSH_URL}"/"$(get_query_options "$query"?T)" > "$TMP1" if [ "$is_macos" != yes ]; then - xsel -bi < "$TMP1" + if [ "$XDG_SESSION_TYPE" = wayland ]; then + wl-copy < "$TMP1" + else + xsel -bi < "$TMP1" + fi else pbcopy < "$TMP1" fi @@ -578,7 +586,11 @@ cmd_ccopy() { else curl -s "${CHTSH_URL}"/"$(get_query_options "$query"?TQ)" > "$TMP1" if [ "$is_macos" != yes ]; then - xsel -bi < "$TMP1" + if [ "$XDG_SESSION_TYPE" = wayland ]; then + wl-copy < "$TMP1" + else + xsel -bi < "$TMP1" + fi else pbcopy < "$TMP1" fi From 064eacf513b5779f5a2f6311a71b94cb5576785e Mon Sep 17 00:00:00 2001 From: Scott Little Date: Fri, 23 Apr 2021 14:10:48 -0500 Subject: [PATCH 2/4] Add wayland support to stealth-mode --- share/cht.sh.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/share/cht.sh.txt b/share/cht.sh.txt index 3b7f125..a4532d8 100755 --- a/share/cht.sh.txt +++ b/share/cht.sh.txt @@ -686,7 +686,11 @@ cmd_stealth() { if [ "$is_macos" = yes ]; then past=$(pbpaste) else - past=$(xsel -o) + if [ "$XDG_SESSION_TYPE" = wayland ]; then + past=$(xl-paste -p) + else + past=$(xsel -o) + fi fi printf "\033[0;31mstealth:\033[0m you are in the stealth mode; select any text in any window for a query\n" printf "\033[0;31mstealth:\033[0m selections longer than $STEALTH_MAX_SELECTION_LENGTH words are ignored\n" @@ -698,7 +702,11 @@ cmd_stealth() { if [ "$is_macos" = yes ]; then current=$(pbpaste) else - current=$(xsel -o) + if [ "$XDG_SESSION_TYPE" = wayland ]; then + current=$(wl-paste -p) + else + current=$(xsel -o) + fi fi if [ "$past" != "$current" ]; then past=$current From 8e789a884fec6b42c45d00b577b87c0dc61f8fb5 Mon Sep 17 00:00:00 2001 From: Scott Little Date: Fri, 23 Apr 2021 14:14:06 -0500 Subject: [PATCH 3/4] Fix typographical error --- share/cht.sh.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/cht.sh.txt b/share/cht.sh.txt index a4532d8..c4520ab 100755 --- a/share/cht.sh.txt +++ b/share/cht.sh.txt @@ -687,7 +687,7 @@ cmd_stealth() { past=$(pbpaste) else if [ "$XDG_SESSION_TYPE" = wayland ]; then - past=$(xl-paste -p) + past=$(wl-paste -p) else past=$(xsel -o) fi From a15c9fdfa52de3b821a2aa5d8f949ca313622fb7 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Sun, 25 Apr 2021 08:41:51 +0200 Subject: [PATCH 4/4] Bump cht.sh version --- share/cht.sh.txt | 4 ++-- tests/results/8 | 34 +++++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/share/cht.sh.txt b/share/cht.sh.txt index c4520ab..2333509 100755 --- a/share/cht.sh.txt +++ b/share/cht.sh.txt @@ -24,8 +24,8 @@ # count words in text counter # group elements list -__CHTSH_VERSION=0.0.2 -__CHTSH_DATETIME="2021-04-23 09:30:30 +0200" +__CHTSH_VERSION=0.0.3 +__CHTSH_DATETIME="2021-04-25 09:30:30 +0200" # cht.sh configuration loading # diff --git a/tests/results/8 b/tests/results/8 index c49ca7b..2333509 100644 --- a/tests/results/8 +++ b/tests/results/8 @@ -24,8 +24,8 @@ # count words in text counter # group elements list -__CHTSH_VERSION=0.0.2 -__CHTSH_DATETIME="2021-04-23 09:30:30 +0200" +__CHTSH_VERSION=0.0.3 +__CHTSH_DATETIME="2021-04-25 09:30:30 +0200" # cht.sh configuration loading # @@ -514,7 +514,11 @@ else fi if [ "$is_macos" != yes ]; then - command -v xsel >/dev/null || echo 'DEPENDENCY: please install "xsel" for "copy"' >&2 + if [ "$XDG_SESSION_TYPE" = wayland ]; then + command -v wl-copy >/dev/null || echo 'DEPENDENCY: please install "wl-copy" for "copy"' >&2 + else + command -v xsel >/dev/null || echo 'DEPENDENCY: please install "xsel" for "copy"' >&2 + fi fi command -v rlwrap >/dev/null || { echo 'DEPENDENCY: install "rlwrap" to use cht.sh in the shell mode' >&2; exit 1; } @@ -562,7 +566,11 @@ cmd_copy() { else curl -s "${CHTSH_URL}"/"$(get_query_options "$query"?T)" > "$TMP1" if [ "$is_macos" != yes ]; then - xsel -bi < "$TMP1" + if [ "$XDG_SESSION_TYPE" = wayland ]; then + wl-copy < "$TMP1" + else + xsel -bi < "$TMP1" + fi else pbcopy < "$TMP1" fi @@ -578,7 +586,11 @@ cmd_ccopy() { else curl -s "${CHTSH_URL}"/"$(get_query_options "$query"?TQ)" > "$TMP1" if [ "$is_macos" != yes ]; then - xsel -bi < "$TMP1" + if [ "$XDG_SESSION_TYPE" = wayland ]; then + wl-copy < "$TMP1" + else + xsel -bi < "$TMP1" + fi else pbcopy < "$TMP1" fi @@ -674,7 +686,11 @@ cmd_stealth() { if [ "$is_macos" = yes ]; then past=$(pbpaste) else - past=$(xsel -o) + if [ "$XDG_SESSION_TYPE" = wayland ]; then + past=$(wl-paste -p) + else + past=$(xsel -o) + fi fi printf "\033[0;31mstealth:\033[0m you are in the stealth mode; select any text in any window for a query\n" printf "\033[0;31mstealth:\033[0m selections longer than $STEALTH_MAX_SELECTION_LENGTH words are ignored\n" @@ -686,7 +702,11 @@ cmd_stealth() { if [ "$is_macos" = yes ]; then current=$(pbpaste) else - current=$(xsel -o) + if [ "$XDG_SESSION_TYPE" = wayland ]; then + current=$(wl-paste -p) + else + current=$(xsel -o) + fi fi if [ "$past" != "$current" ]; then past=$current