aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.example8
-rwxr-xr-xrofi-pass40
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)
diff --git a/rofi-pass b/rofi-pass
index f08d1bc..ba25829 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,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 "$@"
+