Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.

Commit d5e0afc

Browse files
committed
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.
1 parent 79f05b8 commit d5e0afc

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@
4848

4949
# whether to send notifications about copied data via notify-send
5050
# notify="true"
51+
52+
# whether to use the primary clipboard
53+
# use_primary="true"

tessen

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,18 +404,24 @@ wld_copy() {
404404
return 1
405405
fi
406406
fi
407+
408+
local wl_copy_opts
409+
if [[ "${_TSN_USE_PRIMARY}" == "true" ]]; then
410+
wl_copy_opts="-p"
411+
fi
412+
407413
# it would've been better to use, or at least provide an option, to paste
408414
# only once using `wl-copy -o` but web browsers don't work well with this
409415
# feature
410416
# https://github.com/bugaevc/wl-clipboard/issues/107
411-
printf "%s" "$1" | wl-copy
417+
printf "%s" "$1" | wl-copy ${wl_copy_opts}
412418
if [[ $_TSN_NOTIFY == true ]] && is_installed notify-send; then
413419
notify-send -t $((tsn_cliptime * 1000)) \
414420
"data has been copied and will be cleared from the clipboard after $tsn_cliptime seconds"
415421
fi
416422
{
417423
sleep "$tsn_cliptime" || kill 0
418-
wl-copy --clear
424+
wl-copy ${wl_copy_opts} --clear
419425
} > /dev/null 2>&1 &
420426

421427
unset -v tsn_cliptime
@@ -676,6 +682,8 @@ parse_config() {
676682
_TSN_WEB_BROWSER="$val"
677683
elif [[ $key == "notify" ]]; then
678684
_TSN_NOTIFY="$val"
685+
elif [[ $key == "use_primary" ]]; then
686+
_TSN_USE_PRIMARY="$val"
679687
fi
680688
done
681689
fi

0 commit comments

Comments
 (0)