From 486e5faa64915a983328ddddac830e350ebab719 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Wed, 7 Oct 2020 01:44:52 -0400 Subject: [PATCH] Addd binds for QR and deleting items in buffer. --- sway/scripts/clipboard | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/sway/scripts/clipboard b/sway/scripts/clipboard index bf8b347..963004f 100755 --- a/sway/scripts/clipboard +++ b/sway/scripts/clipboard @@ -65,7 +65,6 @@ on-select(){ if [ -z "$result" ]; then exit 0 fi - echo 1 wl-paste local file file="$(parse-file "${result}")" @@ -74,12 +73,11 @@ on-select(){ } menu(){ - #--bind "del:execute-silent($0 delete '{}')+abort" \ list | fzf --read0 +s \ --info=hidden \ --reverse \ -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:: ' \ --pointer='➜' \ --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. - unlock :: like lock, but in reverse. - 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 } +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(){ local file file="$(parse-file "$1")" @@ -118,16 +135,14 @@ preview(){ case "$1" in daemon|on-copy|menu|list) - $1 - echo 3 - wl-paste - ;; + $1;; lock) touch "$workdir/.lock" ; echo "locked";; unlock) rm -f "$workdir/.lock" ; echo "unlocked";; - preview) - shift ; preview "$*";; + preview|delete|qr) + var=$1 + shift ; $var $*;; *) usage;; esac