Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphical session clipboard support #27

Closed
green-green-avk opened this issue Nov 10, 2021 · 5 comments
Closed

Graphical session clipboard support #27

green-green-avk opened this issue Nov 10, 2021 · 5 comments
Assignees
Labels
enhancement New feature or request has workaround A workaround provided

Comments

@green-green-avk
Copy link
Owner

That is it.

@green-green-avk green-green-avk added the enhancement New feature or request label Nov 10, 2021
@green-green-avk green-green-avk self-assigned this Nov 10, 2021
@green-green-avk green-green-avk added this to To do in Another Term Environment via automation Nov 10, 2021
@green-green-avk
Copy link
Owner Author

green-green-avk commented Nov 10, 2021

Workaround:

~/content-base.sh:

#!/bin/bash

DOWNLOADS=~/Downloads/
XCLIPBOARD=~/Xclipboard

mkdir -p "$DOWNLOADS"

msg_err() {
 echo -en '\e[1;37;41m\e[2K\n\e[2K'
 echo " [ $1 ]"
 echo -en '\e[2K\n\e[0m\e[2K'
}

msg_ok() {
 echo -en '\e[1;37;40m\e[2K\n\e[2K [ \e[32m'
 echo -n "$1"
 echo -en '\e[37m ]\n\e[2K\n\e[0m\e[2K'
}

msg_wait() {
 echo -en '\e[?1004h'
 read -n 1 -rs -p '   *** Press any key ***'
 echo -en '\e[?1004l'
}

save_uri() {
 URI="$1"
 if R="$(termsh copy -fu "$URI" -tp "$DOWNLOADS" 2>&1)"
 then
  msg_ok "[$URI] saved to [$DOWNLOADS]"
 else
  msg_err "Failed to save [$URI] to [$DOWNLOADS]: $R"
 fi
}

send_as_text() {
 URI="$1"
 if R="$(termsh cat "$URI" | termsh send --text-stdin 2>&1)"
 then
  msg_ok "Sending [$URI]..."
 else
  msg_err "Failed to send [$URI]: $R"
 fi
}

convert_by() {
 CMD=($1)
 URI="$2"
 EXT="$3"
 TYPE="$4"
 FN="$(termsh name "$URI")"
 if R="$(termsh cat "$URI" | "${CMD[@]}" | termsh send -n "${FN%.*}.$EXT" -m "$TYPE" 2>&1)"
 then
  msg_ok "Sending [$URI]..."
 else
  msg_err "Failed to convert or send [$URI]: $R"
 fi
}

convert_file_by() {
 CMD=($1)
 CMD=("${CMD[0]}" "${CMD[@]}")
 URI="$2"
 EXT="$3"
 TYPE="$4"
 FN="$(termsh name "$URI")"
 if R="$(termsh with-uris "${CMD[@]}" "$URI" | termsh send -n "${FN%.*}.$EXT" -m "$TYPE" 2>&1)"
 then
  msg_ok "Sending [$URI]..."
 else
  msg_err "Failed to convert or send [$URI]: $R"
 fi
}

save_uri_to_xclipboard() {
 URI="$1"
 if R="$(termsh copy -fu "$URI" -tp "$XCLIPBOARD" 2>&1)"
 then
  msg_ok "[$URI] saved to X clipboard"
 else
  msg_err "Failed to save [$URI] to X clipboard: $R"
 fi
}

save_text_to_xclipboard() {
 TEXT="$1"
 if R="$(echo -n "$TEXT" 2>&1 1>"$XCLIPBOARD")"
 then
  msg_ok "'$TEXT' saved to X clipboard"
 else
  msg_err "Failed to save '$TEXT' to X clipboard: $R"
 fi
}

~/content-to-X-clipboard.sh:

#!/bin/bash

. ./content-base.sh

TEXT="$INPUT_TEXT"
TEXT="${TEXT:-$INPUT_SPANNED}"
TEXT="${TEXT:=$INPUT_HTML}"

if [[ -n $TEXT ]]
then
 save_text_to_xclipboard "$TEXT"
 DONE=1
elif [[ -n $INPUT_URI ]]
then
 save_uri_to_xclipboard "$INPUT_URI"
 DONE=1
elif [[ -n $INPUT_URIS ]]
then
 for URI in $INPUT_URIS
 do
  save_uri_to_xclipboard "$URI"
  DONE=1
  break
 done
fi

[[ -z $DONE ]] && msg_err 'Nothing to save'

msg_wait

Profile settings:
Share in "share with" / "open in" dialog: ☑
Execute:

"$DATA_DIR/proots/linuxcontainers-debian-buster/run" '' '~/content-to-X-clipboard.sh'

Another Term settings quick link:

local-terminal:/opts?perm_favmgmt=false&shareable=true&charset=UTF-8&screen_cols=0&screen_rows=0&keymap=&wakelock.acquire_on_connect=true&terminal_string=xterm&perm_pluginexec=true&font_size_auto=false&wakelock.release_on_disconnect=true&execute=%22%24DATA_DIR%2Fproots%2Flinuxcontainers-debian-buster%2Frun%22%20''%20'~%2Fcontent-to-X-clipboard.sh'&name=Copy%20to%20X%20clipboard&term_compliance=ansi&terminate.on_disconnect=true

@green-green-avk
Copy link
Owner Author

#26 (comment)

@green-green-avk
Copy link
Owner Author

Implemented: 9178d9f

@green-green-avk
Copy link
Owner Author

@green-green-avk
Copy link
Owner Author

Done.

Usage of Android international keyboard input and clipboard integration:
https://github.com/green-green-avk/AnotherTerm-scripts/tree/master/Xwayland

Another Term Environment automation moved this from To do to Done Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request has workaround A workaround provided
Projects
Development

No branches or pull requests

1 participant