From d5e0afccf5b0fc54231f3be9cdf61ee93056f019 Mon Sep 17 00:00:00 2001 From: hashworks Date: Thu, 5 Oct 2023 19:15:27 +0200 Subject: [PATCH] Provide a config option to use the primary clipboard When one uses a clipboard manager `wl-copy --clear` doesn't always work correctly. Thus, one gathers a lot of secrets in the clipboard manager. However, the primary clipboard normally isn't read by the clipboard manager, making it an optimal target for secrets. --- config | 3 +++ tessen | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config b/config index 7279c24..a400aca 100644 --- a/config +++ b/config @@ -48,3 +48,6 @@ # whether to send notifications about copied data via notify-send # notify="true" + +# whether to use the primary clipboard +# use_primary="true" diff --git a/tessen b/tessen index 81a7d8b..4cbf964 100755 --- a/tessen +++ b/tessen @@ -404,18 +404,24 @@ wld_copy() { return 1 fi fi + + local wl_copy_opts + if [[ "${_TSN_USE_PRIMARY}" == "true" ]]; then + wl_copy_opts="-p" + fi + # it would've been better to use, or at least provide an option, to paste # only once using `wl-copy -o` but web browsers don't work well with this # feature # https://github.com/bugaevc/wl-clipboard/issues/107 - printf "%s" "$1" | wl-copy + printf "%s" "$1" | wl-copy ${wl_copy_opts} if [[ $_TSN_NOTIFY == true ]] && is_installed notify-send; then notify-send -t $((tsn_cliptime * 1000)) \ "data has been copied and will be cleared from the clipboard after $tsn_cliptime seconds" fi { sleep "$tsn_cliptime" || kill 0 - wl-copy --clear + wl-copy ${wl_copy_opts} --clear } > /dev/null 2>&1 & unset -v tsn_cliptime @@ -676,6 +682,8 @@ parse_config() { _TSN_WEB_BROWSER="$val" elif [[ $key == "notify" ]]; then _TSN_NOTIFY="$val" + elif [[ $key == "use_primary" ]]; then + _TSN_USE_PRIMARY="$val" fi done fi