Skip to content

Commit

Permalink
Provide a config option to use the primary clipboard
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hashworks committed Oct 16, 2023
1 parent 79f05b8 commit acded01
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions config
Original file line number Diff line number Diff line change
Expand Up @@ -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"
12 changes: 10 additions & 2 deletions tessen
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit acded01

Please sign in to comment.