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

Provide a config option to use the primary clipboard #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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