From e8656222b73d213a9d98f5c8dfd7ea38d1b1d500 Mon Sep 17 00:00:00 2001 From: Moviuro Date: Sun, 12 Mar 2017 11:51:26 +0100 Subject: [PATCH 1/5] README.md, rofi-pass: don't run setxkbmap(1) The user has to take care of it, as they're probably smarter than the script. We didn't handle the cases where there were variants (such as `fr bepo`). Having the user fix this during session startup also fixes various other issues in different software (such as sxhkd(1)). --- README.md | 2 +- rofi-pass | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/README.md b/README.md index 5fe857f..732d2d9 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Also included is an import script for keepass2 databases. It's the same script t ## FAQ * rofi pass prints garbage instead of my actual passes -** Set your keyboard layout in config +** Make sure to run `setxkbmap ` at the start of your Xorg session. ## Alternative diff --git a/rofi-pass b/rofi-pass index 53e5de5..e5a66c4 100755 --- a/rofi-pass +++ b/rofi-pass @@ -561,13 +561,6 @@ if [[ ! -d "$HOME/.cache/rofi-pass" ]]; then mkdir "$HOME/.cache/rofi-pass" fi -if [[ -n $keyboard ]]; then - setxkbmap ${keyboard} -else - keyboard=$(setxkbmap -query | grep layout | grep -oE '[^: ]+$') - setxkbmap ${keyboard} -fi - # set help color if [[ $help_color == "" ]]; then help_color=$(rofi -dump-xresources | grep 'rofi.color.normal' | gawk -F ',' '/,/{gsub(/ /, "", $2); print $2}') From 035af66ad4f094b1a7a2a0c36afa7419c56b5bb9 Mon Sep 17 00:00:00 2001 From: Moviuro Date: Sun, 12 Mar 2017 11:55:09 +0100 Subject: [PATCH 2/5] rofi-pass: use current username as default --- rofi-pass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rofi-pass b/rofi-pass index e5a66c4..1d8ea6c 100755 --- a/rofi-pass +++ b/rofi-pass @@ -19,8 +19,8 @@ notify='false' password_length='20' help_color="" clip=primary -default_user=john_doe -default_user2=mary_ann +default_user="$(whoami)" +default_user2=john_doe password_length=12 autotype="Alt+1" type_user="Alt+2" From e5388cb8b16004c045344bfb74962ac28d5a876d Mon Sep 17 00:00:00 2001 From: Moviuro Date: Sun, 12 Mar 2017 11:55:52 +0100 Subject: [PATCH 3/5] rofi-pass: don't override rofi(1)'s option as default An example can still be found in the provided example file --- rofi-pass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rofi-pass b/rofi-pass index 1d8ea6c..2f13a19 100755 --- a/rofi-pass +++ b/rofi-pass @@ -6,7 +6,7 @@ basecommand=$(echo "$0" | gawk '{ print $1 }') # set default settings _rofi () { - rofi -i -width 700 -no-levenshtein-sort "$@" + rofi "$@" } URL_field='url' From fab0475fba86bc4421bff82c1897e94da2fd02a8 Mon Sep 17 00:00:00 2001 From: Moviuro Date: Sun, 12 Mar 2017 11:56:56 +0100 Subject: [PATCH 4/5] rofi-pass: some comments + newlines to let the code breathe --- rofi-pass | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rofi-pass b/rofi-pass index 2f13a19..1adf828 100755 --- a/rofi-pass +++ b/rofi-pass @@ -9,9 +9,11 @@ _rofi () { rofi "$@" } +# We expect to find these fields in pass(1)'s output URL_field='url' USERNAME_field='user' AUTOTYPE_field='autotype' + delay=2 default_do='menu' # menu, copyPass, typeUser, typePass, copyUser, copyUrl, viewEntry, typeMenu, actionMenu, copyMenu, openUrl auto_enter='false' @@ -22,6 +24,8 @@ clip=primary default_user="$(whoami)" default_user2=john_doe password_length=12 + +# default shortcuts autotype="Alt+1" type_user="Alt+2" type_pass="Alt+3" From 19afc1e269ab1e357947b1486da8f47cd9f6487d Mon Sep 17 00:00:00 2001 From: Moviuro Date: Sun, 12 Mar 2017 11:57:30 +0100 Subject: [PATCH 5/5] rofi-pass: use umask instead of chmod. Also avoids race conditions as a happy side effect --- rofi-pass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rofi-pass b/rofi-pass index 1adf828..fcd9282 100755 --- a/rofi-pass +++ b/rofi-pass @@ -43,6 +43,8 @@ help="Alt+h" switch="Alt+x" insert_pass="Alt+n" +# Safe permissions +umask 077 # get all password files and create an array list_passwords() { @@ -69,14 +71,12 @@ doClip () { checkIfPass () { rm -f "$HOME/.cache/rofi-pass/last_used" echo "${root}: $selected_password" > "$HOME/.cache/rofi-pass/last_used" - chmod 600 "$HOME/.cache/rofi-pass/last_used" } autopass () { rm -f "$HOME/.cache/rofi-pass/last_used" echo "${root}: $selected_password" > "$HOME/.cache/rofi-pass/last_used" - chmod 600 "$HOME/.cache/rofi-pass/last_used" if [[ -z "${stuff["$AUTOTYPE_field"]}" ]]; then if [[ "${stuff["${USERNAME_field}"]}" ]]; then echo -n "${stuff["${USERNAME_field}"]}" | xdotool type --clearmodifiers --file -