From 04e61acfe6ae6792b96f640c3f7d4d2006cf9825 Mon Sep 17 00:00:00 2001 From: Rasmus Steinke Date: Thu, 22 Mar 2018 17:20:09 +0100 Subject: change default viewer to feh --- rofi-pass | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/rofi-pass b/rofi-pass index f08d1bc..c334faf 100755 --- a/rofi-pass +++ b/rofi-pass @@ -9,6 +9,10 @@ _rofi () { rofi -no-auto-select -i "$@" } +_image_viewer () { + sxiv - +} + # We expect to find these fields in pass(1)'s output URL_field='url' USERNAME_field='user' @@ -42,11 +46,17 @@ type_menu="Alt+t" help="Alt+h" switch="Alt+x" insert_pass="Alt+n" +qrcode="Alt+q" previous_root="Shift+Left" next_root="Shift+Right" # Safe permissions umask 077 +img_viewer="display" + +has_qrencode() { + command -v qrencode >/dev/null 2>&1 +} # get all password files and create an array list_passwords() { @@ -95,6 +105,35 @@ autopass () { clearUp } +generateQrCode() { + has_qrencode + if [[ $? -eq "1" ]] + then + echo "qrencode not found" | _rofi -dmenu + exit_code=$? + if [[ $exit_code -eq "1" ]] + then + exit + else + "${basecommand}" + fi + fi + checkIfPass + pass "$selected_password" | head -n 1 | qrencode -d 300 -v 8 -l H -o - | _image_viewer + if [[ $? -eq "1" ]] + then + echo "" | _rofi -dmenu -mesg "Image viewer not defined or cannot read from pipe" + exit_value=$? + if [[ $exit_value -eq "1" ]] + then + exit + else + "${basecommand}" + fi + fi + clearUp +} + openURL () { checkIfPass $BROWSER "$(PASSWORD_STORE_DIR="${root}" pass "$selected_password" | grep "${URL_field}: " | gawk '{sub(/:/,"")}{print $2}1' | head -1)"; exit; @@ -308,6 +347,8 @@ mainMenu () { -kb-custom-16 "${help}" -kb-custom-17 "${switch}" -kb-custom-18 "${insert_pass}" + -kb-custom-19 "${qrcode}") + args+=( -kb-mode-previous "" # These keyboard shortcut options are needed, because -kb-mode-next "" # Shift+ are otherwise taken by rofi. -select "$entry" @@ -402,6 +443,7 @@ mainMenu () { 23) actionMenu;; 24) copyMenu;; 27) insertPass;; + 28) generateQrCode;; esac clearUp } @@ -421,6 +463,7 @@ helpMenu () { printf '%s' "${autotype}: Autotype ${type_user}: Type Username ${type_pass}: Type Password +${qrcode}: Generate and display qrcode --- ${copy_name}: Copy Username ${copy_pass}: Copy Password @@ -805,3 +848,4 @@ main () { } main "$@" + -- cgit