modernize UI
This commit is contained in:
parent
f71c27746f
commit
6f8c3d803e
129
rofi-pass
129
rofi-pass
@ -18,15 +18,20 @@ list_passwords() {
|
||||
}
|
||||
|
||||
doClip () {
|
||||
if [[ $clip == "primary" ]]; then xclip;
|
||||
elif [[ $clip == "clipboard" ]]; then xclip -selection clipboard;
|
||||
elif [[ $clip == "both" ]]; then xclip; xclip -o | xclip -selection clipboard;
|
||||
if [[ $clip == "primary" ]]; then
|
||||
xclip
|
||||
elif [[ $clip == "clipboard" ]]; then
|
||||
xclip -selection clipboard;
|
||||
elif [[ $clip == "both" ]]; then
|
||||
xclip; xclip -o | xclip -selection clipboard;
|
||||
fi
|
||||
}
|
||||
|
||||
checkIfPass () {
|
||||
if [[ $selected_password == "[ Add Entry ]>" ]]; then mainMenu;
|
||||
elif [[ $selected_password == "---" ]]; then mainMenu;
|
||||
if [[ $selected_password == "[ Add Entry ]>" ]]; then
|
||||
mainMenu;
|
||||
elif [[ $selected_password == "---" ]]; then
|
||||
mainMenu;
|
||||
else
|
||||
rm -f "/tmp/$USER-rofi-pass/last_used"
|
||||
echo "${root}: $selected_password" > "/tmp/$USER-rofi-pass/last_used"
|
||||
@ -35,8 +40,10 @@ checkIfPass () {
|
||||
|
||||
|
||||
autopass () {
|
||||
if [[ ${selected_password} == "[ Add Entry ]>" ]]; then insertPass;
|
||||
elif [[ ${selected_password} == "---" ]]; then mainMenu;
|
||||
if [[ ${selected_password} == "[ Add Entry ]>" ]]; then
|
||||
insertPass;
|
||||
elif [[ ${selected_password} == "---" ]]; then
|
||||
mainMenu;
|
||||
else
|
||||
rm -f "/tmp/$USER-rofi-pass/last_used"
|
||||
echo "${root}: $selected_password" > "/tmp/$USER-rofi-pass/last_used"
|
||||
@ -47,19 +54,29 @@ autopass () {
|
||||
fi
|
||||
echo -n "${password}" | xdotool type --clearmodifiers --file -
|
||||
sleep 1
|
||||
if [[ ${auto_enter} == "true" ]]; then xdotool key Return; fi
|
||||
if [[ ${auto_enter} == "true" ]]; then
|
||||
xdotool key Return
|
||||
fi
|
||||
else
|
||||
echo "${stuff["$AUTOTYPE_field"]}"
|
||||
for word in ${stuff["$AUTOTYPE_field"]}; do
|
||||
if [[ $word == ":tab" ]]; then xdotool key Tab;
|
||||
elif [[ $word == ":space" ]]; then xdotool key space;
|
||||
elif [[ $word == ":delay" ]]; then sleep "${delay}";
|
||||
elif [[ $word == ":enter" ]]; then xdotool key Return;
|
||||
elif [[ $word == "pass" ]]; then echo -n "${password}" | xdotool type --clearmodifiers --file -;
|
||||
else echo -n "${stuff[${word}]}" | xdotool type --clearmodifiers --file -
|
||||
if [[ $word == ":tab" ]]; then
|
||||
xdotool key Tab;
|
||||
elif [[ $word == ":space" ]]; then
|
||||
xdotool key space
|
||||
elif [[ $word == ":delay" ]]; then
|
||||
sleep "${delay}";
|
||||
elif [[ $word == ":enter" ]]; then
|
||||
xdotool key Return;
|
||||
elif [[ $word == "pass" ]]; then
|
||||
echo -n "${password}" | xdotool type --clearmodifiers --file -;
|
||||
else
|
||||
echo -n "${stuff[${word}]}" | xdotool type --clearmodifiers --file -
|
||||
fi
|
||||
done
|
||||
if [[ ${auto_enter} == "true" ]]; then xdotool key Return; fi
|
||||
if [[ ${auto_enter} == "true" ]]; then
|
||||
xdotool key Return
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -80,10 +97,12 @@ typePass () {
|
||||
if [[ $notify == "true" ]]; then
|
||||
if [[ "${stuff[notify]}" == "false" ]]; then
|
||||
:
|
||||
else notify-send "rofi-pass" "finished typing password";
|
||||
else
|
||||
notify-send "rofi-pass" "finished typing password";
|
||||
fi
|
||||
elif [[ $notify == "false" ]]; then
|
||||
if [[ "${stuff[notify]}" == "true" ]]; then notify-send "rofi-pass" "finished typing password";
|
||||
if [[ "${stuff[notify]}" == "true" ]]; then
|
||||
notify-send "rofi-pass" "finished typing password";
|
||||
else
|
||||
:
|
||||
fi
|
||||
@ -134,15 +153,20 @@ generatePass () {
|
||||
|
||||
checkIfPass
|
||||
symbols=$(echo -e "0 Cancel\n---\n1 Yes\n2 No" | rofi -dmenu -p "Use Symbols? > ")
|
||||
if [[ $symbols == "0 Cancel" ]]; then mainMenu;
|
||||
elif [[ $symbols == "1 Yes" ]]; then symbols="";
|
||||
elif [[ $symbols == "2 No" ]]; then symbols="-n";
|
||||
if [[ $symbols == "0 Cancel" ]]; then
|
||||
mainMenu;
|
||||
elif [[ $symbols == "1 Yes" ]]; then
|
||||
symbols="";
|
||||
elif [[ $symbols == "2 No" ]]; then
|
||||
symbols="-n";
|
||||
fi
|
||||
HELP="<span color='$help_color'>Enter Number or hit Enter to use default length</span>"
|
||||
length=$(echo -e "" | _rofi -dmenu -mesg "${HELP}" -p "Password length? (Default: ${passlength}) > ")
|
||||
askGen
|
||||
if [[ $length == "" ]]; then pass generate ${symbols} -i "$selected_password" "${passlength}" > /dev/null;
|
||||
else pass generate ${symbols} -i "$selected_password" "${length}" > /dev/null;
|
||||
if [[ $length == "" ]]; then
|
||||
pass generate ${symbols} -i "$selected_password" "${passlength}" > /dev/null;
|
||||
else
|
||||
pass generate ${symbols} -i "$selected_password" "${length}" > /dev/null;
|
||||
fi
|
||||
}
|
||||
|
||||
@ -167,12 +191,9 @@ mainMenu () {
|
||||
fi
|
||||
else
|
||||
unset selected_password
|
||||
help_text=$({ echo -e "Enter: Autotype - ${action_menu}: Actions - ${show}: View"; echo "${type_menu}: Type Field - ${copy_menu}: Copy Field - ${help}: Help";} | column -s '-' -t)
|
||||
line1=$(echo "${help_text}" | head -1)
|
||||
line3=$(echo "${help_text}" | tail -1)
|
||||
HELP="<span color='$help_color'>${line1}
|
||||
${line3}</span>"
|
||||
selected_password="$({ echo -e "[ Add Entry ]>\n---"; list_passwords 2>/dev/null;} \
|
||||
HELP="Welcome to rofi-pass. Use <span color='$help_color'>${insert_pass}</span> to create a new pass entry.
|
||||
To type User/Pass use <span color='$help_color'>Enter</span>. For more help hit <span color='$help_color'>${help}</span>."
|
||||
selected_password="$(list_passwords 2>/dev/null \
|
||||
| _rofi -mesg "${HELP}" \
|
||||
-dmenu -kb-accept-entry '!Return' -kb-custom-1 "${autotype}" \
|
||||
-kb-custom-2 "${type_user}" \
|
||||
@ -246,12 +267,13 @@ ${type_menu}: Type Custom Field
|
||||
${copy_name}: Copy Username
|
||||
${copy_pass}: Copy Password
|
||||
${copy_url}: Copy URL
|
||||
${open_url}: Open URL
|
||||
${copy_menu}: Copy Custom Field
|
||||
---
|
||||
${action_menu}: Edit, Move, Delete, Re-generate Submenu
|
||||
${show}: Show Password File
|
||||
${insert_pass}: Insert new Pass Entry
|
||||
${switch}: Switch Pass/Bookmark Mode" | _rofi -dmenu -p "Help > ")
|
||||
${switch}: Switch Pass/Bookmark Mode" | _rofi -dmenu -mesg "Hint: All hotkeys are configurable in config file" -p "Help > ")
|
||||
help_val=$?
|
||||
if [[ $help_val -eq 1 ]]; then exit;
|
||||
else unset helptext; mainMenu; fi
|
||||
@ -300,18 +322,24 @@ copyMenu () {
|
||||
actionMenu () {
|
||||
checkIfPass
|
||||
action=$(echo -e "< Return\n---\n1 Move Password File\n2 Delete Password File\\n3 Edit Password File\n4 Generate New Password" | _rofi -kb-accept-entry '!Return' -dmenu -p "Choose Action > ")
|
||||
if [[ ${action} == "1 Move Password File" ]]; then manageEntry move;
|
||||
elif [[ ${action} == "2 Delete Password File" ]]; then manageEntry delete;
|
||||
elif [[ ${action} == "3 Edit Password File" ]]; then manageEntry edit;
|
||||
elif [[ ${action} == "4 Generate New Password" ]]; then generatePass;
|
||||
elif [[ ${action} == "< Return" ]]; then mainMenu;
|
||||
elif [[ ${action} == "" ]]; then exit
|
||||
if [[ ${action} == "1 Move Password File" ]]; then
|
||||
manageEntry move;
|
||||
elif [[ ${action} == "2 Delete Password File" ]]; then
|
||||
manageEntry delete;
|
||||
elif [[ ${action} == "3 Edit Password File" ]]; then
|
||||
manageEntry edit;
|
||||
elif [[ ${action} == "4 Generate New Password" ]]; then
|
||||
generatePass;
|
||||
elif [[ ${action} == "< Return" ]]; then
|
||||
mainMenu;
|
||||
elif [[ ${action} == "" ]]; then
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
showEntry () {
|
||||
HELP="<span color='$help_color'>${type_entry}: Type Entry | ${copy_entry}: Copy Entry</span>"
|
||||
bla=$({ echo -e "0 Return\n---"; PASSWORD_STORE_DIR="${root}" pass "$selected_password";} | _rofi -kb-accept-entry '!Return' -dmenu -mesg "${HELP}" -p "> ")
|
||||
bla=$({ echo -e "< Return\n---"; PASSWORD_STORE_DIR="${root}" pass "$selected_password";} | _rofi -kb-accept-entry '!Return' -dmenu -mesg "${HELP}" -p "> ")
|
||||
rofi_exit=$?
|
||||
password_temp=$(PASSWORD_STORE_DIR="${root}" pass "$selected_password")
|
||||
password=$(echo "${password_temp}" | head -1)
|
||||
@ -321,21 +349,21 @@ showEntry () {
|
||||
_id=$(echo "${LINE}" | gawk -F ':[[:space:]]*' '{print $1}')
|
||||
_val=$(echo "${LINE}" | gawk '{sub(/:/,"")}{for (i=2; i<NF; i++) printf $i " "; print $NF}')
|
||||
stuff["${_id}"]=${_val}
|
||||
|
||||
done < <(PASSWORD_STORE_DIR="${root}" pass "${selected_password}" | tail -n+2 | grep -P '(: |:\t)' )
|
||||
stuff["pass"]=${password}
|
||||
|
||||
word=$(echo "$bla" | gawk -F': ' '{print $1}')
|
||||
if [[ ${rofi_exit} -eq 0 ]]; then
|
||||
if [[ $bla == "" ]]; then exit
|
||||
elif [[ $bla == "0 Return" ]]; then
|
||||
if [[ $bla == "" ]]; then
|
||||
exit
|
||||
elif [[ $bla == "< Return" ]]; then
|
||||
selected_password=""
|
||||
mainMenu
|
||||
fi
|
||||
elif [[ ${rofi_exit} -eq 1 ]]; then
|
||||
exit
|
||||
elif [[ ${rofi_exit} -eq 11 ]]; then
|
||||
if [[ ${bla} == "0 Return" ]]; then
|
||||
if [[ ${bla} == "< Return" ]]; then
|
||||
echo "not doing anything"
|
||||
else
|
||||
if [[ -z $(echo -n "${stuff[${word}]}") ]]; then
|
||||
@ -346,10 +374,9 @@ showEntry () {
|
||||
notify-send "rofi-pass" "Copied Password\nClearing in 45 seconds"
|
||||
$(sleep 45; echo -n "" | xclip; echo "" | xclip -selection clipboard | notify-send "rofi-pass" "Clipboard cleared") &
|
||||
exit
|
||||
|
||||
fi
|
||||
elif [[ ${rofi_exit} -eq 10 ]]; then
|
||||
if [[ ${bla} == "0 Return" ]]; then
|
||||
if [[ ${bla} == "< Return" ]]; then
|
||||
echo "not doing anything"
|
||||
else
|
||||
if [[ -z $(echo -n "${stuff[${word}]}") ]]; then
|
||||
@ -380,15 +407,15 @@ manageEntry () {
|
||||
if [[ "$1" == "edit" ]]; then
|
||||
EDITOR=$EDITOR PASSWORD_STORE_DIR="${root}" pass edit "${selected_password}"
|
||||
mainMenu
|
||||
|
||||
elif [[ $1 == "move" ]]; then
|
||||
cd "${root}" || exit
|
||||
selected_password2=$(basename "$selected_password" .gpg)
|
||||
group=$(find -type d -not -iwholename '*.git*' -printf '%d\t%P\n' | sort -r -nk1 | cut -f2- | _rofi -dmenu -p "Choose Group > ")
|
||||
if [[ $group == "" ]]; then exit; fi
|
||||
if [[ $group == "" ]]; then
|
||||
exit
|
||||
fi
|
||||
PASSWORD_STORE_DIR="${root}" pass mv "$selected_password" "${group}"
|
||||
mainMenu
|
||||
|
||||
elif [[ "$1" == "delete" ]]; then
|
||||
HELP="<span color='$help_color'>Selected entry: ${selected_password}</span>"
|
||||
ask=$(echo -e "Yes\nNo" | _rofi -mesg "${HELP}" -dmenu -p "Are You Sure? > ")
|
||||
@ -414,13 +441,19 @@ insertPass () {
|
||||
name="$(listgpg | rofi -dmenu -format 'f' -mesg "Type name, make sure it is unique" -p "> ")"
|
||||
# name="$(echo -e "$(list_passwords 2>/dev/null)" | rofi -dmenu -mesg "Type name, make sure it is unique" -p "> ")"
|
||||
val=$?
|
||||
if [[ $val -eq 1 ]]; then exit; fi
|
||||
if [[ $val -eq 1 ]]; then
|
||||
exit
|
||||
fi
|
||||
user=$(echo -e "${default_user2}\n$USER\n${default_user}" | rofi -dmenu -mesg "Chose Username or type" -p "> ")
|
||||
val=$?
|
||||
if [[ $val -eq 1 ]]; then exit; fi
|
||||
if [[ $val -eq 1 ]]; then
|
||||
exit
|
||||
fi
|
||||
group=$(echo -e "No Group\n---\n$(find -type d -not -iwholename '*.git*' -printf '%d\t%P\n' | sort -r -nk1 | cut -f2-)" | rofi -dmenu -p "Choose Group > ")
|
||||
val=$?
|
||||
if [[ $val -eq 1 ]]; then exit; fi
|
||||
if [[ $val -eq 1 ]]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ "$group" == "No Group" ]]; then
|
||||
if [[ $url == http* ]]; then
|
||||
|
Loading…
x
Reference in New Issue
Block a user