Addd binds for QR and deleting items in buffer.

This commit is contained in:
James Patrick 2020-10-07 01:44:52 -04:00
parent 10a658bd5b
commit 486e5faa64

View File

@ -65,7 +65,6 @@ on-select(){
if [ -z "$result" ]; then if [ -z "$result" ]; then
exit 0 exit 0
fi fi
echo 1
wl-paste wl-paste
local file local file
file="$(parse-file "${result}")" file="$(parse-file "${result}")"
@ -74,12 +73,11 @@ on-select(){
} }
menu(){ menu(){
#--bind "del:execute-silent($0 delete '{}')+abort" \
list | fzf --read0 +s \ list | fzf --read0 +s \
--info=hidden \ --info=hidden \
--reverse \ --reverse \
-d "${delim}" --nth ..2 --with-nth 2 \ -d "${delim}" --nth ..2 --with-nth 2 \
--bind="del:execute()" \ --bind="del:execute-silent($0 delete {})+reload($0 list),f1:execute($0 qr {})" \
--prompt='clip:: ' \ --prompt='clip:: ' \
--pointer='➜' \ --pointer='➜' \
--color="gutter:0,prompt:4" \ --color="gutter:0,prompt:4" \
@ -101,9 +99,28 @@ Hello, this is the usuage menu. $0 supports the following arguments.
- lock :: prevents daemon/on-clip from saving value. Use for passwords, etc. - lock :: prevents daemon/on-clip from saving value. Use for passwords, etc.
- unlock :: like lock, but in reverse. - unlock :: like lock, but in reverse.
- preview :: the preview used by fzf. Requires clip file. - preview :: the preview used by fzf. Requires clip file.
- delete :: deletes the file, requires file.
- qr :: bind to f1. Displays a qr code of the value.
EOF EOF
} }
qr(){
local file
file="$(parse-file "$1")"
cat $file |
qrencode -o - \
--size=25 \
--background=161720 \
--foreground=AAB5C6 |
feh -
}
delete(){
local file
file="$(parse-file "$1")"
rm $file
}
preview(){ preview(){
local file local file
file="$(parse-file "$1")" file="$(parse-file "$1")"
@ -118,16 +135,14 @@ preview(){
case "$1" in case "$1" in
daemon|on-copy|menu|list) daemon|on-copy|menu|list)
$1 $1;;
echo 3
wl-paste
;;
lock) lock)
touch "$workdir/.lock" ; echo "locked";; touch "$workdir/.lock" ; echo "locked";;
unlock) unlock)
rm -f "$workdir/.lock" ; echo "unlocked";; rm -f "$workdir/.lock" ; echo "unlocked";;
preview) preview|delete|qr)
shift ; preview "$*";; var=$1
shift ; $var $*;;
*) *)
usage;; usage;;
esac esac