Adds wl-clip support to password manager
This commit is contained in:
parent
9fbdb83d70
commit
fcbd5f3637
1 changed files with 18 additions and 5 deletions
|
@ -6,6 +6,17 @@ extraArgs=""
|
||||||
|
|
||||||
hostname | grep -q 'phone' && extraArgs="-normal-window"
|
hostname | grep -q 'phone' && extraArgs="-normal-window"
|
||||||
|
|
||||||
|
function clipboard(){
|
||||||
|
text="$(cat -)"
|
||||||
|
if [ -n "$WAYLAND_DISPLAY" ]; then
|
||||||
|
echo "$text" | wl-copy
|
||||||
|
echo "$text" | wl-copy --primary
|
||||||
|
else
|
||||||
|
echo "$text" | xclip -selection "primary"
|
||||||
|
echo "$text" | xclip -selection "clipboard"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function type_password(){
|
function type_password(){
|
||||||
local password="$1"
|
local password="$1"
|
||||||
local pw=$(pass "$password" | head -n 1)
|
local pw=$(pass "$password" | head -n 1)
|
||||||
|
@ -26,7 +37,11 @@ function copy_password(){
|
||||||
local password="$1"
|
local password="$1"
|
||||||
local part="${2:-0}"
|
local part="${2:-0}"
|
||||||
local sleep_argv0="jh password store sleep on display $DISPLAY"
|
local sleep_argv0="jh password store sleep on display $DISPLAY"
|
||||||
local before="$(xclip -o -selection clipboard 2>/dev/null | base64)"
|
if [ -n "$WAYLAND_DISPLAY" ]; then
|
||||||
|
local before="$(wl-paste 2>/dev/null | base64)"
|
||||||
|
else
|
||||||
|
local before="$(xclip -o -selection clipboard 2>/dev/null | base64)"
|
||||||
|
fi
|
||||||
pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
|
pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
|
||||||
local pw=""
|
local pw=""
|
||||||
case "$part" in
|
case "$part" in
|
||||||
|
@ -40,14 +55,12 @@ function copy_password(){
|
||||||
if [ -z "$pw" ]; then
|
if [ -z "$pw" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "$pw" | xclip -selection "primary"
|
echo "$pw" | clipboard
|
||||||
echo "$pw" | xclip -selection "clipboard"
|
|
||||||
notify-send -t 3000 "Password put on clipboard" "Will be removed in 3 seconds"
|
notify-send -t 3000 "Password put on clipboard" "Will be removed in 3 seconds"
|
||||||
(
|
(
|
||||||
( exec -a "$sleep_argv0" bash <<<"trap 'kill %1' TERM; sleep '3' & wait" )
|
( exec -a "$sleep_argv0" bash <<<"trap 'kill %1' TERM; sleep '3' & wait" )
|
||||||
|
|
||||||
echo "$before" | base64 -d | xclip -selection "primary"
|
echo "$before" | base64 -d | clipboard
|
||||||
echo "$before" | base64 -d | xclip -selection "clipboard"
|
|
||||||
|
|
||||||
notify-send "Password Clearerd"
|
notify-send "Password Clearerd"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue