Change pass fix. Comments don't need "comments:"
This commit is contained in:
parent
f24871770f
commit
7ef0ecf62b
|
@ -18,40 +18,54 @@ info="$(echo "Yes\nNo" | rofi -dmenu -i -p "Change info?")"
|
|||
|
||||
[ -z $(echo "$info" | grep -E "(Yes|No)") ] && exit 0
|
||||
|
||||
generate="$(echo "Yes\nNo" | rofi -dmenu -i -p "Generate password?")"
|
||||
change="$(echo "Yes\nNo" | rofi -dmenu -i -p "Change password?")"
|
||||
if [ "$change" = "Yes" ]; then
|
||||
generate="$(echo "Yes\nNo" | rofi -dmenu -i -p "Generate password?")"
|
||||
[ -z $(echo "$generate" | grep -E "(Yes|No)") ] && exit 0
|
||||
fi
|
||||
|
||||
[ -z $(echo "$generate" | grep -E "(Yes|No)") ] && exit 0
|
||||
|
||||
contents_nopass="$(pass show "$page_relative" | tail -n +2)"
|
||||
passw="$(pass show "$page_relative")"
|
||||
contents_nopass="$(echo "$passw" | tail -n +2)"
|
||||
passw="$(echo "$passw" | head -n 1)"
|
||||
|
||||
if [ "$info" = "Yes" ]; then
|
||||
file="/tmp/change-pass$(date +%s)"
|
||||
echo "$contents_nopass" > "$file"
|
||||
cp "$file" "$file-copy"
|
||||
$TERMINAL -e $EDITOR "$file"
|
||||
[ -z "$(cat $file)" ] && notify-send "Operation CANCELLED" && exit 1
|
||||
[ -z "${TERMINAL##*termite*}" ] && $TERMINAL -e "$EDITOR $file" || \
|
||||
$TERMINAL -e $EDITOR $file
|
||||
[ -z "$(cat $file)" ] && notify-send "Operation CANCELLED" && \
|
||||
rm "$file" "$file-copy" && exit 1
|
||||
[ -z "$(diff "$file" "$file-copy")" ] && notify-send "Operation CANCELLED" \
|
||||
&& exit 1
|
||||
&& rm "$file" "$file-copy" && exit 1
|
||||
contents_nopass="$(cat "$file")"
|
||||
rm "$file" "$file-copy"
|
||||
fi
|
||||
|
||||
|
||||
if [ "$generate" = "Yes" ]; then
|
||||
contents="$(pwgen -ysBv 15 -N 1)\n$contents_nopass"
|
||||
if [ "$change" = "Yes" ]; then
|
||||
if [ "$generate" = "Yes" ]; then
|
||||
contents="$(pwgen -ysBv 15 -N 1)"
|
||||
else
|
||||
tries=0
|
||||
while [ "$tries" -ne 3 ]; do
|
||||
passwd="$(rofi -i -dmenu -password -p "Type")"
|
||||
passwdcheck="$(rofi -i -dmenu -password -p "Type Again")"
|
||||
[ "$passwd" != "$passwdcheck" ] || break \
|
||||
&& notify-send "Passwords are not equal"
|
||||
tries="$(( $tries + 1 ))"
|
||||
done
|
||||
[ "$passwd" != "$passwdcheck" ] && notify-send "Operation CANCELLED" && \
|
||||
exit 1
|
||||
contents="$passwd"
|
||||
fi
|
||||
|
||||
contents="$contents\n$contents_nopass"
|
||||
else
|
||||
tries=0
|
||||
while [ "$tries" -ne 3 ]; do
|
||||
passwd="$(rofi -i -dmenu -password -p "Type")"
|
||||
passwdcheck="$(rofi -i -dmenu -password -p "Type Again")"
|
||||
[ "$passwd" != "$passwdcheck" ] || break \
|
||||
&& notify-send "Passwords are not equal"
|
||||
tries="$(( $tries + 1 ))"
|
||||
done
|
||||
[ "$passwd" != "$passwdcheck" ] && notify-send "Operation CANCELLED" && \
|
||||
exit 1
|
||||
contents="$passwd\n$contents_nopass"
|
||||
contents="$passw\n$contents_nopass"
|
||||
fi
|
||||
|
||||
echo "$contents" | pass insert -m "$page_relative" || \
|
||||
(notify-send "Error: pass insert" && exit 1)
|
||||
if [ -n "$contents" ]; then
|
||||
echo "$contents" | pass insert -m "$page_relative" || \
|
||||
(notify-send "Error: pass insert" && exit 1)
|
||||
fi
|
||||
|
|
|
@ -8,10 +8,13 @@ site="$(find "$PASSWORD_STORE_DIR" -name "*.gpg" -type f | \
|
|||
|
||||
comments="$(pass show "$site" | sed '1d')"
|
||||
|
||||
num="$(echo "$comments" | grep -n "comments:" | sed '1q;d' | \
|
||||
awk '{print $1}' | sed -r 's|([^:]*):.*|\1|')"
|
||||
# num="$(echo "$comments" | grep -n "comments:" | sed '1q;d' | \
|
||||
# awk '{print $1}' | sed -r 's|([^:]*):.*|\1|')"
|
||||
|
||||
[ "$num" -ne 1 ] && comments="$(echo "$comments" | sed "1,$(( $num - 1 ))d")"
|
||||
# [ "$num" -ne 1 ] && comments="$(echo "$comments" | sed "1,$(( $num - 1 ))d")"
|
||||
|
||||
notify-send "This terminal will close in 45 seconds"
|
||||
st -e $SCRIPTS/eval.sh "echo \"$comments\" && sleep 45"
|
||||
|
||||
[ -z "${TERMINAL##*termite*}" ] && \
|
||||
$TERMINAL -e "$SCRIPTS/eval.sh \"echo \\\"$comments\\\" && sleep 45\"" \
|
||||
|| $TERMINAL -e $SCRIPTS/eval.sh "echo \"$comments\" && sleep 45"
|
||||
|
|
Loading…
Reference in a new issue