diff options
author | Rasmus Steinke <rasi@xssn.at> | 2018-03-22 17:14:56 +0100 |
---|---|---|
committer | Rasmus Steinke <rasi@xssn.at> | 2018-03-22 17:14:56 +0100 |
commit | 75bda54fced238dfb593c466f9be13427235600f (patch) | |
tree | 5ab8a417d1686338a6ff4306ce8a4ff6eb946d30 | |
parent | 8a5a12e5907e7fa1db3294605e2e542e125e94d4 (diff) | |
download | rofi-pass-75bda54fced238dfb593c466f9be13427235600f.tar.gz |
add qrcode support
-rw-r--r-- | config.example | 8 | ||||
-rwxr-xr-x | rofi-pass | 40 |
2 files changed, 48 insertions, 0 deletions
diff --git a/config.example b/config.example index 52ba160..6524c4b 100644 --- a/config.example +++ b/config.example @@ -7,6 +7,14 @@ _rofi () { rofi -i -no-auto-select "$@" } +# rofi-pass can create a qrcode for selected entry. +# This needs qrencode to be installed and an image +# viewer that supports reading from a pipe. +# Working viewers are feh and display +_image_viewer () { + feh - +} + # xdotool needs the keyboard layout to be set using setxkbmap # You can do this in your autostart scripts (e.g. xinitrc) @@ -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,31 @@ autopass () { clearUp } +generateQrCode() { + has_qrencode + if [[ $? -eq "1" ]] + then + echo "qrencode not found" | _rofi -dmenu + exit_code=$? + if [[ $exit_code -eq "1" ]] + then + exit + 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 + 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 +343,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+<Left|Right> are otherwise taken by rofi. -select "$entry" @@ -402,6 +439,7 @@ mainMenu () { 23) actionMenu;; 24) copyMenu;; 27) insertPass;; + 28) generateQrCode;; esac clearUp } @@ -421,6 +459,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 +844,4 @@ main () { } main "$@" + |