From 38a3be4a3eeacec75a534fef6951b9484b4d7098 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Wed, 28 Oct 2020 14:12:54 +0000 Subject: feature: copy password to clipboard --- lpass_copy.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 lpass_copy.sh (limited to 'lpass_copy.sh') diff --git a/lpass_copy.sh b/lpass_copy.sh new file mode 100755 index 0000000..9499dec --- /dev/null +++ b/lpass_copy.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +error() { + echo "$@" + exit 1 +} + +if [[ -z $1 ]]; then + error "Error: nothing to copy" +fi + +if [[ -n $WAYLAND_DISLPLAY ]]; then + command=(wl-copy) + if [[ $X_SELECTION == primary ]]; then + command+=( --primary ) + fi +elif [[ -n $DISPLAY ]]; then + command=(xclip -selection clipboard) +else + error "Error: X11 or Wayland display were not detected" +fi + +echo "$1" | "${command[@]}" || error "Error: failed to copy data to clipboard" +echo "Password copied to clipboard." \ No newline at end of file -- cgit v1.2.3-18-g5258