modernize UI
This commit is contained in:
parent
f71c27746f
commit
6f8c3d803e
777
rofi-pass
777
rofi-pass
@ -7,238 +7,259 @@ basecommand=$(echo "$0" | gawk '{ print $1 }')
|
|||||||
|
|
||||||
# get all password files and create an array
|
# get all password files and create an array
|
||||||
list_passwords() {
|
list_passwords() {
|
||||||
cd "${root}" || exit
|
cd "${root}" || exit
|
||||||
passwords=( **/*.gpg )
|
passwords=( **/*.gpg )
|
||||||
|
|
||||||
for password in "${passwords[@]}"; do
|
for password in "${passwords[@]}"; do
|
||||||
filename="${password}"
|
filename="${password}"
|
||||||
filename="${filename%.gpg}"
|
filename="${filename%.gpg}"
|
||||||
echo "$filename"
|
echo "$filename"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
doClip () {
|
doClip () {
|
||||||
if [[ $clip == "primary" ]]; then xclip;
|
if [[ $clip == "primary" ]]; then
|
||||||
elif [[ $clip == "clipboard" ]]; then xclip -selection clipboard;
|
xclip
|
||||||
elif [[ $clip == "both" ]]; then xclip; xclip -o | xclip -selection clipboard;
|
elif [[ $clip == "clipboard" ]]; then
|
||||||
fi
|
xclip -selection clipboard;
|
||||||
|
elif [[ $clip == "both" ]]; then
|
||||||
|
xclip; xclip -o | xclip -selection clipboard;
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
checkIfPass () {
|
checkIfPass () {
|
||||||
if [[ $selected_password == "[ Add Entry ]>" ]]; then mainMenu;
|
if [[ $selected_password == "[ Add Entry ]>" ]]; then
|
||||||
elif [[ $selected_password == "---" ]]; then mainMenu;
|
mainMenu;
|
||||||
else
|
elif [[ $selected_password == "---" ]]; then
|
||||||
rm -f "/tmp/$USER-rofi-pass/last_used"
|
mainMenu;
|
||||||
echo "${root}: $selected_password" > "/tmp/$USER-rofi-pass/last_used"
|
else
|
||||||
fi
|
rm -f "/tmp/$USER-rofi-pass/last_used"
|
||||||
|
echo "${root}: $selected_password" > "/tmp/$USER-rofi-pass/last_used"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
autopass () {
|
autopass () {
|
||||||
if [[ ${selected_password} == "[ Add Entry ]>" ]]; then insertPass;
|
if [[ ${selected_password} == "[ Add Entry ]>" ]]; then
|
||||||
elif [[ ${selected_password} == "---" ]]; then mainMenu;
|
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"
|
||||||
|
if [[ -z "${stuff["$AUTOTYPE_field"]}" ]]; then
|
||||||
|
if [[ "${stuff["${USERNAME_field}"]}" ]]; then
|
||||||
|
echo -n "${stuff["${USERNAME_field}"]}" | xdotool type --clearmodifiers --file -
|
||||||
|
xdotool key Tab
|
||||||
|
fi
|
||||||
|
echo -n "${password}" | xdotool type --clearmodifiers --file -
|
||||||
|
sleep 1
|
||||||
|
if [[ ${auto_enter} == "true" ]]; then
|
||||||
|
xdotool key Return
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
rm -f "/tmp/$USER-rofi-pass/last_used"
|
echo "${stuff["$AUTOTYPE_field"]}"
|
||||||
echo "${root}: $selected_password" > "/tmp/$USER-rofi-pass/last_used"
|
for word in ${stuff["$AUTOTYPE_field"]}; do
|
||||||
if [[ -z "${stuff["$AUTOTYPE_field"]}" ]]; then
|
if [[ $word == ":tab" ]]; then
|
||||||
if [[ "${stuff["${USERNAME_field}"]}" ]]; then
|
xdotool key Tab;
|
||||||
echo -n "${stuff["${USERNAME_field}"]}" | xdotool type --clearmodifiers --file -
|
elif [[ $word == ":space" ]]; then
|
||||||
xdotool key Tab
|
xdotool key space
|
||||||
fi
|
elif [[ $word == ":delay" ]]; then
|
||||||
echo -n "${password}" | xdotool type --clearmodifiers --file -
|
sleep "${delay}";
|
||||||
sleep 1
|
elif [[ $word == ":enter" ]]; then
|
||||||
if [[ ${auto_enter} == "true" ]]; then xdotool key Return; fi
|
xdotool key Return;
|
||||||
|
elif [[ $word == "pass" ]]; then
|
||||||
|
echo -n "${password}" | xdotool type --clearmodifiers --file -;
|
||||||
else
|
else
|
||||||
echo "${stuff["$AUTOTYPE_field"]}"
|
echo -n "${stuff[${word}]}" | xdotool type --clearmodifiers --file -
|
||||||
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 -
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [[ ${auto_enter} == "true" ]]; then xdotool key Return; fi
|
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
if [[ ${auto_enter} == "true" ]]; then
|
||||||
|
xdotool key Return
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
openURL () {
|
openURL () {
|
||||||
checkIfPass
|
checkIfPass
|
||||||
$BROWSER "$(pass "$selected_password" | grep "${URL_field}: " | gawk '{sub(/:/,"")}{print $2}1' | head -1)"; exit;
|
$BROWSER "$(pass "$selected_password" | grep "${URL_field}: " | gawk '{sub(/:/,"")}{print $2}1' | head -1)"; exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
typeUser () {
|
typeUser () {
|
||||||
checkIfPass
|
checkIfPass
|
||||||
echo -n "${stuff[${USERNAME_field}]}" | xdotool type --clearmodifiers --file -
|
echo -n "${stuff[${USERNAME_field}]}" | xdotool type --clearmodifiers --file -
|
||||||
}
|
}
|
||||||
|
|
||||||
typePass () {
|
typePass () {
|
||||||
checkIfPass
|
checkIfPass
|
||||||
echo -n "${password}" | xdotool type --clearmodifiers --file -
|
echo -n "${password}" | xdotool type --clearmodifiers --file -
|
||||||
if [[ $notify == "true" ]]; then
|
if [[ $notify == "true" ]]; then
|
||||||
if [[ "${stuff[notify]}" == "false" ]]; then
|
if [[ "${stuff[notify]}" == "false" ]]; then
|
||||||
:
|
:
|
||||||
else notify-send "rofi-pass" "finished typing password";
|
else
|
||||||
fi
|
notify-send "rofi-pass" "finished typing password";
|
||||||
elif [[ $notify == "false" ]]; then
|
|
||||||
if [[ "${stuff[notify]}" == "true" ]]; then notify-send "rofi-pass" "finished typing password";
|
|
||||||
else
|
|
||||||
:
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
elif [[ $notify == "false" ]]; then
|
||||||
|
if [[ "${stuff[notify]}" == "true" ]]; then
|
||||||
|
notify-send "rofi-pass" "finished typing password";
|
||||||
|
else
|
||||||
|
:
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
typeField () {
|
typeField () {
|
||||||
checkIfPass
|
checkIfPass
|
||||||
echo -n "${stuff[${typefield}]}" | xdotool type --clearmodifiers --file -
|
echo -n "${stuff[${typefield}]}" | xdotool type --clearmodifiers --file -
|
||||||
}
|
}
|
||||||
|
|
||||||
copyUser () {
|
copyUser () {
|
||||||
checkIfPass
|
checkIfPass
|
||||||
echo -n "${stuff[${USERNAME_field}]}" | doClip
|
echo -n "${stuff[${USERNAME_field}]}" | doClip
|
||||||
}
|
}
|
||||||
|
|
||||||
copyField () {
|
copyField () {
|
||||||
checkIfPass
|
checkIfPass
|
||||||
echo -n "${stuff[${copyfield}]}" | doClip
|
echo -n "${stuff[${copyfield}]}" | doClip
|
||||||
}
|
}
|
||||||
|
|
||||||
copyURL () {
|
copyURL () {
|
||||||
checkIfPass
|
checkIfPass
|
||||||
echo -n "${stuff[${URL_field}]}" | doClip
|
echo -n "${stuff[${URL_field}]}" | doClip
|
||||||
}
|
}
|
||||||
|
|
||||||
copyPass () {
|
copyPass () {
|
||||||
checkIfPass
|
checkIfPass
|
||||||
echo -n "$password" | doClip
|
echo -n "$password" | doClip
|
||||||
notify-send "rofi-pass" "Copied Password\nClearing in 45 seconds"
|
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") &
|
$(sleep 45; echo -n "" | xclip; echo "" | xclip -selection clipboard | notify-send "rofi-pass" "Clipboard cleared") &
|
||||||
}
|
}
|
||||||
|
|
||||||
viewEntry () {
|
viewEntry () {
|
||||||
checkIfPass
|
checkIfPass
|
||||||
showEntry "${selected_password}"
|
showEntry "${selected_password}"
|
||||||
}
|
}
|
||||||
|
|
||||||
generatePass () {
|
generatePass () {
|
||||||
askGen () {
|
askGen () {
|
||||||
askGenMenu=$(echo -e "Yes\nNo" | rofi -dmenu -p "Generate new Password for ${selected_password}? > ")
|
askGenMenu=$(echo -e "Yes\nNo" | rofi -dmenu -p "Generate new Password for ${selected_password}? > ")
|
||||||
if [[ $askGenMenu == "Yes" ]]; then
|
if [[ $askGenMenu == "Yes" ]]; then
|
||||||
true
|
true
|
||||||
elif [[ $askGenMenu == "No" ]]; then
|
elif [[ $askGenMenu == "No" ]]; then
|
||||||
generatePass
|
generatePass
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
checkIfPass
|
checkIfPass
|
||||||
symbols=$(echo -e "0 Cancel\n---\n1 Yes\n2 No" | rofi -dmenu -p "Use Symbols? > ")
|
symbols=$(echo -e "0 Cancel\n---\n1 Yes\n2 No" | rofi -dmenu -p "Use Symbols? > ")
|
||||||
if [[ $symbols == "0 Cancel" ]]; then mainMenu;
|
if [[ $symbols == "0 Cancel" ]]; then
|
||||||
elif [[ $symbols == "1 Yes" ]]; then symbols="";
|
mainMenu;
|
||||||
elif [[ $symbols == "2 No" ]]; then symbols="-n";
|
elif [[ $symbols == "1 Yes" ]]; then
|
||||||
fi
|
symbols="";
|
||||||
HELP="<span color='$help_color'>Enter Number or hit Enter to use default length</span>"
|
elif [[ $symbols == "2 No" ]]; then
|
||||||
length=$(echo -e "" | _rofi -dmenu -mesg "${HELP}" -p "Password length? (Default: ${passlength}) > ")
|
symbols="-n";
|
||||||
askGen
|
fi
|
||||||
if [[ $length == "" ]]; then pass generate ${symbols} -i "$selected_password" "${passlength}" > /dev/null;
|
HELP="<span color='$help_color'>Enter Number or hit Enter to use default length</span>"
|
||||||
else pass generate ${symbols} -i "$selected_password" "${length}" > /dev/null;
|
length=$(echo -e "" | _rofi -dmenu -mesg "${HELP}" -p "Password length? (Default: ${passlength}) > ")
|
||||||
fi
|
askGen
|
||||||
|
if [[ $length == "" ]]; then
|
||||||
|
pass generate ${symbols} -i "$selected_password" "${passlength}" > /dev/null;
|
||||||
|
else
|
||||||
|
pass generate ${symbols} -i "$selected_password" "${length}" > /dev/null;
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# main Menu
|
# main Menu
|
||||||
mainMenu () {
|
mainMenu () {
|
||||||
if [[ $1 == "--bmarks" ]]; then
|
if [[ $1 == "--bmarks" ]]; then
|
||||||
selected_password="$(list_passwords 2>/dev/null \
|
selected_password="$(list_passwords 2>/dev/null \
|
||||||
| _rofi -kb-accept-entry '!Return' -mesg "Bookmarks Mode. ${switch} to switch" \
|
| _rofi -kb-accept-entry '!Return' -mesg "Bookmarks Mode. ${switch} to switch" \
|
||||||
-dmenu \
|
-dmenu \
|
||||||
-kb-custom-1 "Alt+x" \
|
-kb-custom-1 "Alt+x" \
|
||||||
-select "$entry" \
|
-select "$entry" \
|
||||||
-p "rofi-pass > ")"
|
-p "rofi-pass > ")"
|
||||||
|
|
||||||
rofi_exit=$?
|
rofi_exit=$?
|
||||||
|
|
||||||
if [[ $rofi_exit -eq 1 ]]; then
|
if [[ $rofi_exit -eq 1 ]]; then
|
||||||
exit
|
exit
|
||||||
elif [[ $rofi_exit -eq 10 ]]; then
|
elif [[ $rofi_exit -eq 10 ]]; then
|
||||||
$(${basecommand})
|
$(${basecommand})
|
||||||
elif [[ $rofi_exit -eq 0 ]]; then
|
elif [[ $rofi_exit -eq 0 ]]; then
|
||||||
openURL
|
openURL
|
||||||
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;} \
|
|
||||||
| _rofi -mesg "${HELP}" \
|
|
||||||
-dmenu -kb-accept-entry '!Return' -kb-custom-1 "${autotype}" \
|
|
||||||
-kb-custom-2 "${type_user}" \
|
|
||||||
-kb-custom-3 "${type_pass}" \
|
|
||||||
-kb-custom-4 "${open_url}" \
|
|
||||||
-kb-custom-5 "${copy_name}" \
|
|
||||||
-kb-custom-6 "${copy_pass}" \
|
|
||||||
-kb-custom-7 "${show}" \
|
|
||||||
-kb-custom-8 "${copy_url}" \
|
|
||||||
-kb-custom-13 "${type_menu}" \
|
|
||||||
-kb-custom-14 "${action_menu}" \
|
|
||||||
-kb-custom-15 "${copy_menu}" \
|
|
||||||
-kb-custom-16 "${help}" \
|
|
||||||
-kb-custom-17 "${switch}" \
|
|
||||||
-kb-custom-18 "${insert_pass}" \
|
|
||||||
-dmenu \
|
|
||||||
-select "$entry" \
|
|
||||||
-p "rofi-pass > ")"
|
|
||||||
|
|
||||||
rofi_exit=$?
|
|
||||||
|
|
||||||
if [[ ${selected_password} == "[ Add Entry ]>" ]]; then
|
|
||||||
:
|
|
||||||
else
|
|
||||||
# generate Array of fields
|
|
||||||
password_temp=$(PASSWORD_STORE_DIR="${root}" pass "$selected_password")
|
|
||||||
password=$(echo "${password_temp}" | head -1)
|
|
||||||
declare -A stuff
|
|
||||||
while read -r LINE; do
|
|
||||||
_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}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# actions based on keypresses
|
|
||||||
if [[ "${rofi_exit}" -eq 0 ]]; then ${default_do};
|
|
||||||
elif [[ "${rofi_exit}" -eq 13 ]]; then openURL;
|
|
||||||
elif [[ "${rofi_exit}" -eq 1 ]]; then exit ${rofi_exit};
|
|
||||||
elif [[ "${rofi_exit}" -eq 10 ]]; then autopass;
|
|
||||||
elif [[ "${rofi_exit}" -eq 11 ]]; then typeUser;
|
|
||||||
elif [[ "${rofi_exit}" -eq 12 ]]; then typePass;
|
|
||||||
elif [[ "${rofi_exit}" -eq 14 ]]; then copyUser;
|
|
||||||
elif [[ "${rofi_exit}" -eq 17 ]]; then copyURL;
|
|
||||||
elif [[ "${rofi_exit}" -eq 16 ]]; then viewEntry;
|
|
||||||
elif [[ "${rofi_exit}" -eq 15 ]]; then copyPass;
|
|
||||||
elif [[ "${rofi_exit}" -eq 22 ]]; then typeMenu;
|
|
||||||
elif [[ "${rofi_exit}" -eq 23 ]]; then actionMenu;
|
|
||||||
elif [[ "${rofi_exit}" -eq 25 ]]; then unset selected_password; helpMenu;
|
|
||||||
elif [[ "${rofi_exit}" -eq 24 ]]; then copyMenu;
|
|
||||||
elif [[ "${rofi_exit}" -eq 26 ]]; then $(${basecommand} --bmarks);
|
|
||||||
elif [[ "${rofi_exit}" -eq 27 ]]; then insertPass;
|
|
||||||
fi
|
|
||||||
password=''
|
|
||||||
selected_password=''
|
|
||||||
unset stuff
|
|
||||||
unset password
|
|
||||||
unset selected_password
|
|
||||||
unset password_temp
|
|
||||||
unset stuff
|
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
unset selected_password
|
||||||
|
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}" \
|
||||||
|
-kb-custom-3 "${type_pass}" \
|
||||||
|
-kb-custom-4 "${open_url}" \
|
||||||
|
-kb-custom-5 "${copy_name}" \
|
||||||
|
-kb-custom-6 "${copy_pass}" \
|
||||||
|
-kb-custom-7 "${show}" \
|
||||||
|
-kb-custom-8 "${copy_url}" \
|
||||||
|
-kb-custom-13 "${type_menu}" \
|
||||||
|
-kb-custom-14 "${action_menu}" \
|
||||||
|
-kb-custom-15 "${copy_menu}" \
|
||||||
|
-kb-custom-16 "${help}" \
|
||||||
|
-kb-custom-17 "${switch}" \
|
||||||
|
-kb-custom-18 "${insert_pass}" \
|
||||||
|
-dmenu \
|
||||||
|
-select "$entry" \
|
||||||
|
-p "rofi-pass > ")"
|
||||||
|
|
||||||
|
rofi_exit=$?
|
||||||
|
|
||||||
|
if [[ ${selected_password} == "[ Add Entry ]>" ]]; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
# generate Array of fields
|
||||||
|
password_temp=$(PASSWORD_STORE_DIR="${root}" pass "$selected_password")
|
||||||
|
password=$(echo "${password_temp}" | head -1)
|
||||||
|
declare -A stuff
|
||||||
|
while read -r LINE; do
|
||||||
|
_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}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# actions based on keypresses
|
||||||
|
if [[ "${rofi_exit}" -eq 0 ]]; then ${default_do};
|
||||||
|
elif [[ "${rofi_exit}" -eq 13 ]]; then openURL;
|
||||||
|
elif [[ "${rofi_exit}" -eq 1 ]]; then exit ${rofi_exit};
|
||||||
|
elif [[ "${rofi_exit}" -eq 10 ]]; then autopass;
|
||||||
|
elif [[ "${rofi_exit}" -eq 11 ]]; then typeUser;
|
||||||
|
elif [[ "${rofi_exit}" -eq 12 ]]; then typePass;
|
||||||
|
elif [[ "${rofi_exit}" -eq 14 ]]; then copyUser;
|
||||||
|
elif [[ "${rofi_exit}" -eq 17 ]]; then copyURL;
|
||||||
|
elif [[ "${rofi_exit}" -eq 16 ]]; then viewEntry;
|
||||||
|
elif [[ "${rofi_exit}" -eq 15 ]]; then copyPass;
|
||||||
|
elif [[ "${rofi_exit}" -eq 22 ]]; then typeMenu;
|
||||||
|
elif [[ "${rofi_exit}" -eq 23 ]]; then actionMenu;
|
||||||
|
elif [[ "${rofi_exit}" -eq 25 ]]; then unset selected_password; helpMenu;
|
||||||
|
elif [[ "${rofi_exit}" -eq 24 ]]; then copyMenu;
|
||||||
|
elif [[ "${rofi_exit}" -eq 26 ]]; then $(${basecommand} --bmarks);
|
||||||
|
elif [[ "${rofi_exit}" -eq 27 ]]; then insertPass;
|
||||||
|
fi
|
||||||
|
password=''
|
||||||
|
selected_password=''
|
||||||
|
unset stuff
|
||||||
|
unset password
|
||||||
|
unset selected_password
|
||||||
|
unset password_temp
|
||||||
|
unset stuff
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
helpMenu () {
|
helpMenu () {
|
||||||
helptext=$(echo -e "${autotype}: Autotype
|
helptext=$(echo -e "${autotype}: Autotype
|
||||||
${type_user}: Type Username
|
${type_user}: Type Username
|
||||||
${type_pass}: Type Password
|
${type_pass}: Type Password
|
||||||
${type_menu}: Type Custom Field
|
${type_menu}: Type Custom Field
|
||||||
@ -246,208 +267,220 @@ ${type_menu}: Type Custom Field
|
|||||||
${copy_name}: Copy Username
|
${copy_name}: Copy Username
|
||||||
${copy_pass}: Copy Password
|
${copy_pass}: Copy Password
|
||||||
${copy_url}: Copy URL
|
${copy_url}: Copy URL
|
||||||
|
${open_url}: Open URL
|
||||||
${copy_menu}: Copy Custom Field
|
${copy_menu}: Copy Custom Field
|
||||||
---
|
---
|
||||||
${action_menu}: Edit, Move, Delete, Re-generate Submenu
|
${action_menu}: Edit, Move, Delete, Re-generate Submenu
|
||||||
${show}: Show Password File
|
${show}: Show Password File
|
||||||
${insert_pass}: Insert new Pass Entry
|
${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=$?
|
help_val=$?
|
||||||
if [[ $help_val -eq 1 ]]; then exit;
|
if [[ $help_val -eq 1 ]]; then exit;
|
||||||
else unset helptext; mainMenu; fi
|
else unset helptext; mainMenu; fi
|
||||||
}
|
}
|
||||||
|
|
||||||
typeMenu () {
|
typeMenu () {
|
||||||
checkIfPass
|
checkIfPass
|
||||||
typefield=$({ echo -e "< Return\n---\npassword"; \
|
typefield=$({ echo -e "< Return\n---\npassword"; \
|
||||||
pass "${selected_password}" \
|
pass "${selected_password}" \
|
||||||
| grep -P ':[\t ]' \
|
| grep -P ':[\t ]' \
|
||||||
| gawk -F ':' '{ print $1 }';} \
|
| gawk -F ':' '{ print $1 }';} \
|
||||||
| _rofi -kb-accept-entry '!Return' \
|
| _rofi -kb-accept-entry '!Return' \
|
||||||
-dmenu \
|
-dmenu \
|
||||||
-p "Choose Field to type > ")
|
-p "Choose Field to type > ")
|
||||||
if [[ $typefield == "" ]]; then
|
if [[ $typefield == "" ]]; then
|
||||||
exit;
|
exit;
|
||||||
elif [[ $typefield == "password" ]]; then
|
elif [[ $typefield == "password" ]]; then
|
||||||
typePass;
|
typePass;
|
||||||
elif [[ $typefield == "< Return" ]]; then
|
elif [[ $typefield == "< Return" ]]; then
|
||||||
mainMenu;
|
mainMenu;
|
||||||
else
|
else
|
||||||
typeField
|
typeField
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
copyMenu () {
|
copyMenu () {
|
||||||
checkIfPass
|
checkIfPass
|
||||||
copyfield=$({ echo -e "< Return\n---\npassword"; \
|
copyfield=$({ echo -e "< Return\n---\npassword"; \
|
||||||
pass "${selected_password}" \
|
pass "${selected_password}" \
|
||||||
| grep -P ':[\t ]' \
|
| grep -P ':[\t ]' \
|
||||||
| gawk -F ':' '{ print $1 }';} \
|
| gawk -F ':' '{ print $1 }';} \
|
||||||
| _rofi -kb-accept-entry '!Return' \
|
| _rofi -kb-accept-entry '!Return' \
|
||||||
-dmenu \
|
-dmenu \
|
||||||
-p "Choose Field to copy > ")
|
-p "Choose Field to copy > ")
|
||||||
if [[ $copyfield == "" ]]; then
|
if [[ $copyfield == "" ]]; then
|
||||||
exit;
|
exit;
|
||||||
elif [[ $copyfield == "password" ]]; then
|
elif [[ $copyfield == "password" ]]; then
|
||||||
copyPass;
|
copyPass;
|
||||||
elif [[ $copyfield == "< Return" ]]; then
|
elif [[ $copyfield == "< Return" ]]; then
|
||||||
mainMenu;
|
mainMenu;
|
||||||
else
|
else
|
||||||
copyField
|
copyField
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
actionMenu () {
|
actionMenu () {
|
||||||
checkIfPass
|
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 > ")
|
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;
|
if [[ ${action} == "1 Move Password File" ]]; then
|
||||||
elif [[ ${action} == "2 Delete Password File" ]]; then manageEntry delete;
|
manageEntry move;
|
||||||
elif [[ ${action} == "3 Edit Password File" ]]; then manageEntry edit;
|
elif [[ ${action} == "2 Delete Password File" ]]; then
|
||||||
elif [[ ${action} == "4 Generate New Password" ]]; then generatePass;
|
manageEntry delete;
|
||||||
elif [[ ${action} == "< Return" ]]; then mainMenu;
|
elif [[ ${action} == "3 Edit Password File" ]]; then
|
||||||
elif [[ ${action} == "" ]]; then exit
|
manageEntry edit;
|
||||||
fi
|
elif [[ ${action} == "4 Generate New Password" ]]; then
|
||||||
|
generatePass;
|
||||||
|
elif [[ ${action} == "< Return" ]]; then
|
||||||
|
mainMenu;
|
||||||
|
elif [[ ${action} == "" ]]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
showEntry () {
|
showEntry () {
|
||||||
HELP="<span color='$help_color'>${type_entry}: Type Entry | ${copy_entry}: Copy Entry</span>"
|
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=$?
|
rofi_exit=$?
|
||||||
password_temp=$(PASSWORD_STORE_DIR="${root}" pass "$selected_password")
|
password_temp=$(PASSWORD_STORE_DIR="${root}" pass "$selected_password")
|
||||||
password=$(echo "${password_temp}" | head -1)
|
password=$(echo "${password_temp}" | head -1)
|
||||||
declare -A stuff
|
declare -A stuff
|
||||||
|
|
||||||
while read -r LINE; do
|
while read -r LINE; do
|
||||||
_id=$(echo "${LINE}" | gawk -F ':[[:space:]]*' '{print $1}')
|
_id=$(echo "${LINE}" | gawk -F ':[[:space:]]*' '{print $1}')
|
||||||
_val=$(echo "${LINE}" | gawk '{sub(/:/,"")}{for (i=2; i<NF; i++) printf $i " "; print $NF}')
|
_val=$(echo "${LINE}" | gawk '{sub(/:/,"")}{for (i=2; i<NF; i++) printf $i " "; print $NF}')
|
||||||
stuff["${_id}"]=${_val}
|
stuff["${_id}"]=${_val}
|
||||||
|
done < <(PASSWORD_STORE_DIR="${root}" pass "${selected_password}" | tail -n+2 | grep -P '(: |:\t)' )
|
||||||
|
stuff["pass"]=${password}
|
||||||
|
|
||||||
done < <(PASSWORD_STORE_DIR="${root}" pass "${selected_password}" | tail -n+2 | grep -P '(: |:\t)' )
|
word=$(echo "$bla" | gawk -F': ' '{print $1}')
|
||||||
stuff["pass"]=${password}
|
if [[ ${rofi_exit} -eq 0 ]]; then
|
||||||
|
if [[ $bla == "" ]]; then
|
||||||
word=$(echo "$bla" | gawk -F': ' '{print $1}')
|
exit
|
||||||
if [[ ${rofi_exit} -eq 0 ]]; then
|
elif [[ $bla == "< Return" ]]; then
|
||||||
if [[ $bla == "" ]]; then exit
|
selected_password=""
|
||||||
elif [[ $bla == "0 Return" ]]; then
|
mainMenu
|
||||||
selected_password=""
|
|
||||||
mainMenu
|
|
||||||
fi
|
|
||||||
elif [[ ${rofi_exit} -eq 1 ]]; then
|
|
||||||
exit
|
|
||||||
elif [[ ${rofi_exit} -eq 11 ]]; then
|
|
||||||
if [[ ${bla} == "0 Return" ]]; then
|
|
||||||
echo "not doing anything"
|
|
||||||
else
|
|
||||||
if [[ -z $(echo -n "${stuff[${word}]}") ]]; then
|
|
||||||
echo -n "$word" | doClip
|
|
||||||
else
|
|
||||||
echo -n "${stuff[${word}]}" | doClip
|
|
||||||
fi
|
|
||||||
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
|
|
||||||
echo "not doing anything"
|
|
||||||
else
|
|
||||||
if [[ -z $(echo -n "${stuff[${word}]}") ]]; then
|
|
||||||
xdotool type "${word}"
|
|
||||||
else
|
|
||||||
echo -n "${stuff[${word}]}" | xdotool type --clearmodifiers --file -
|
|
||||||
xdotool key ctrl+alt
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [[ ${count} == "off" ]]; then
|
|
||||||
exit
|
|
||||||
else
|
|
||||||
sleep "${count}"
|
|
||||||
fi
|
|
||||||
showEntry
|
|
||||||
elif [[ ${rofi_exit} -eq 1 ]]; then
|
|
||||||
exit
|
|
||||||
fi
|
fi
|
||||||
unset stuff
|
elif [[ ${rofi_exit} -eq 1 ]]; then
|
||||||
unset password
|
|
||||||
unset selected_password
|
|
||||||
unset password_temp
|
|
||||||
unset stuff
|
|
||||||
exit
|
exit
|
||||||
|
elif [[ ${rofi_exit} -eq 11 ]]; then
|
||||||
|
if [[ ${bla} == "< Return" ]]; then
|
||||||
|
echo "not doing anything"
|
||||||
|
else
|
||||||
|
if [[ -z $(echo -n "${stuff[${word}]}") ]]; then
|
||||||
|
echo -n "$word" | doClip
|
||||||
|
else
|
||||||
|
echo -n "${stuff[${word}]}" | doClip
|
||||||
|
fi
|
||||||
|
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} == "< Return" ]]; then
|
||||||
|
echo "not doing anything"
|
||||||
|
else
|
||||||
|
if [[ -z $(echo -n "${stuff[${word}]}") ]]; then
|
||||||
|
xdotool type "${word}"
|
||||||
|
else
|
||||||
|
echo -n "${stuff[${word}]}" | xdotool type --clearmodifiers --file -
|
||||||
|
xdotool key ctrl+alt
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ ${count} == "off" ]]; then
|
||||||
|
exit
|
||||||
|
else
|
||||||
|
sleep "${count}"
|
||||||
|
fi
|
||||||
|
showEntry
|
||||||
|
elif [[ ${rofi_exit} -eq 1 ]]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
unset stuff
|
||||||
|
unset password
|
||||||
|
unset selected_password
|
||||||
|
unset password_temp
|
||||||
|
unset stuff
|
||||||
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
manageEntry () {
|
manageEntry () {
|
||||||
if [[ "$1" == "edit" ]]; then
|
if [[ "$1" == "edit" ]]; then
|
||||||
EDITOR=$EDITOR PASSWORD_STORE_DIR="${root}" pass edit "${selected_password}"
|
EDITOR=$EDITOR PASSWORD_STORE_DIR="${root}" pass edit "${selected_password}"
|
||||||
mainMenu
|
mainMenu
|
||||||
|
elif [[ $1 == "move" ]]; then
|
||||||
elif [[ $1 == "move" ]]; then
|
cd "${root}" || exit
|
||||||
cd "${root}" || exit
|
selected_password2=$(basename "$selected_password" .gpg)
|
||||||
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 > ")
|
||||||
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
|
||||||
if [[ $group == "" ]]; then exit; fi
|
exit
|
||||||
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? > ")
|
|
||||||
if [[ "$ask" == "Yes" ]]; then
|
|
||||||
PASSWORD_STORE_DIR="${root}" pass rm --force "${selected_password}"
|
|
||||||
elif [[ "$ask" == "No" ]]; then
|
|
||||||
mainMenu
|
|
||||||
elif [[ -z "$ask" ]]; then
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
mainMenu
|
|
||||||
fi
|
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? > ")
|
||||||
|
if [[ "$ask" == "Yes" ]]; then
|
||||||
|
PASSWORD_STORE_DIR="${root}" pass rm --force "${selected_password}"
|
||||||
|
elif [[ "$ask" == "No" ]]; then
|
||||||
|
mainMenu
|
||||||
|
elif [[ -z "$ask" ]]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
mainMenu
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
listgpg () {
|
listgpg () {
|
||||||
find . -name \*.gpg -print | cut -c 3- | while read line; do echo -e "${line##*/}\t(In: ${line%%/*})"; done | sed 's/(.*.gpg)$//g; s/.gpg\t/\t/g' | column -s $'\t' -t
|
find . -name \*.gpg -print | cut -c 3- | while read line; do echo -e "${line##*/}\t(In: ${line%%/*})"; done | sed 's/(.*.gpg)$//g; s/.gpg\t/\t/g' | column -s $'\t' -t
|
||||||
}
|
}
|
||||||
|
|
||||||
insertPass () {
|
insertPass () {
|
||||||
url=$(xclip -o)
|
url=$(xclip -o)
|
||||||
cd "${root}"
|
cd "${root}"
|
||||||
name="$(listgpg | rofi -dmenu -format 'f' -mesg "Type name, make sure it is unique" -p "> ")"
|
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 "> ")"
|
# name="$(echo -e "$(list_passwords 2>/dev/null)" | rofi -dmenu -mesg "Type name, make sure it is unique" -p "> ")"
|
||||||
val=$?
|
val=$?
|
||||||
if [[ $val -eq 1 ]]; then exit; fi
|
if [[ $val -eq 1 ]]; then
|
||||||
user=$(echo -e "${default_user2}\n$USER\n${default_user}" | rofi -dmenu -mesg "Chose Username or type" -p "> ")
|
exit
|
||||||
val=$?
|
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 "> ")
|
||||||
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=$?
|
||||||
val=$?
|
if [[ $val -eq 1 ]]; then
|
||||||
if [[ $val -eq 1 ]]; then exit; fi
|
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 [[ "$group" == "No Group" ]]; then
|
if [[ "$group" == "No Group" ]]; then
|
||||||
if [[ $url == http* ]]; then
|
if [[ $url == http* ]]; then
|
||||||
echo -e "PASS\n---\n${USERNAME_field}: $user\n${URL_field}: $url" | PASSWORD_STORE_DIR="${root}" pass insert -m "${name}" > /dev/null && PASSWORD_STORE_DIR="${root}" pass generate -ni "${name}" "${password_length}" >/dev/null && PASSWORD_STORE_DIR="${root}" pass edit "${name}"
|
echo -e "PASS\n---\n${USERNAME_field}: $user\n${URL_field}: $url" | PASSWORD_STORE_DIR="${root}" pass insert -m "${name}" > /dev/null && PASSWORD_STORE_DIR="${root}" pass generate -ni "${name}" "${password_length}" >/dev/null && PASSWORD_STORE_DIR="${root}" pass edit "${name}"
|
||||||
else
|
|
||||||
echo -e "PASS\n---\n${USERNAME_field}: $user" | PASSWORD_STORE_DIR="${root}" pass insert -m "${name}" > /dev/null && PASSWORD_STORE_DIR="${root}" pass generate -ni "${name}" "${password_length}" >/dev/null && PASSWORD_STORE_DIR="${root}" pass edit "${name}"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
if [[ $url == http* ]]; then
|
echo -e "PASS\n---\n${USERNAME_field}: $user" | PASSWORD_STORE_DIR="${root}" pass insert -m "${name}" > /dev/null && PASSWORD_STORE_DIR="${root}" pass generate -ni "${name}" "${password_length}" >/dev/null && PASSWORD_STORE_DIR="${root}" pass edit "${name}"
|
||||||
echo -e "PASS\n---\n${USERNAME_field}: $user\n${URL_field}: $url" | PASSWORD_STORE_DIR="${root}" pass insert -m "${group}/${name}" > /dev/null && PASSWORD_STORE_DIR="${root}" pass generate -ni "${group}/${name}" "${password_length}" >/dev/null && PASSWORD_STORE_DIR="${root}" pass edit "${group}/${name}"
|
|
||||||
else
|
|
||||||
echo -e "PASS\n---\n${USERNAME_field}: $user" | PASSWORD_STORE_DIR="${root}" pass insert -m "${group}/${name}" > /dev/null && PASSWORD_STORE_DIR="${root}" pass generate -ni "${group}/${name}" "${password_length}" >/dev/null && PASSWORD_STORE_DIR="${root}" pass edit "${group}/${name}"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
if [[ $url == http* ]]; then
|
||||||
|
echo -e "PASS\n---\n${USERNAME_field}: $user\n${URL_field}: $url" | PASSWORD_STORE_DIR="${root}" pass insert -m "${group}/${name}" > /dev/null && PASSWORD_STORE_DIR="${root}" pass generate -ni "${group}/${name}" "${password_length}" >/dev/null && PASSWORD_STORE_DIR="${root}" pass edit "${group}/${name}"
|
||||||
|
else
|
||||||
|
echo -e "PASS\n---\n${USERNAME_field}: $user" | PASSWORD_STORE_DIR="${root}" pass insert -m "${group}/${name}" > /dev/null && PASSWORD_STORE_DIR="${root}" pass generate -ni "${group}/${name}" "${password_length}" >/dev/null && PASSWORD_STORE_DIR="${root}" pass edit "${group}/${name}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
help_msg () {
|
help_msg () {
|
||||||
echo "rofi-pass (Version: 1.2)"
|
echo "rofi-pass (Version: 1.2)"
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "Usage:\n"
|
echo -e "Usage:\n"
|
||||||
echo "--insert insert new entry to password store"
|
echo "--insert insert new entry to password store"
|
||||||
echo "--manage edit/move/delete entries"
|
echo "--manage edit/move/delete entries"
|
||||||
echo -e "--root set custom root directory"
|
echo -e "--root set custom root directory"
|
||||||
echo "--last-used highlight last used item"
|
echo "--last-used highlight last used item"
|
||||||
echo "--show-last show details of last used Entry"
|
echo "--show-last show details of last used Entry"
|
||||||
echo "--bmarks run bookmarks Mode"
|
echo "--bmarks run bookmarks Mode"
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
main () {
|
main () {
|
||||||
@ -456,78 +489,78 @@ shopt -s nullglob globstar
|
|||||||
|
|
||||||
# check if global config exists and load it
|
# check if global config exists and load it
|
||||||
if [[ -f /etc/rofi-pass.conf ]]; then
|
if [[ -f /etc/rofi-pass.conf ]]; then
|
||||||
source /etc/rofi-pass.conf
|
source /etc/rofi-pass.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if local config exists and load it
|
# check if local config exists and load it
|
||||||
if [[ -f "$HOME/.config/rofi-pass/config" ]]; then
|
if [[ -f "$HOME/.config/rofi-pass/config" ]]; then
|
||||||
source "$HOME/.config/rofi-pass/config"
|
source "$HOME/.config/rofi-pass/config"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create tmp dir
|
# create tmp dir
|
||||||
if [[ ! -d /tmp/$USER-rofi-pass ]]; then
|
if [[ ! -d /tmp/$USER-rofi-pass ]]; then
|
||||||
mkdir "/tmp/$USER-rofi-pass"
|
mkdir "/tmp/$USER-rofi-pass"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# set help color
|
# set help color
|
||||||
if [[ $help_color == "" ]]; then
|
if [[ $help_color == "" ]]; then
|
||||||
help_color=$(rofi -dump-xresources | grep 'rofi.color.normal' | gawk -F ',' '/,/{gsub(/ /, "", $2); print $2}')
|
help_color=$(rofi -dump-xresources | grep 'rofi.color.normal' | gawk -F ',' '/,/{gsub(/ /, "", $2); print $2}')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check for BROWSER variable, use xdg-open as fallback
|
# check for BROWSER variable, use xdg-open as fallback
|
||||||
if [[ -z $BROWSER ]]; then
|
if [[ -z $BROWSER ]]; then
|
||||||
export BROWSER=xdg-open
|
export BROWSER=xdg-open
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z ${count} ]]; then
|
if [[ -z ${count} ]]; then
|
||||||
count=2
|
count=2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if alternative root directory was given on commandline
|
# check if alternative root directory was given on commandline
|
||||||
if [[ -r "/tmp/$USER-rofi-pass/last_used" ]] && [[ $1 == "--last-used" || $1 == "--show-last" ]]; then
|
if [[ -r "/tmp/$USER-rofi-pass/last_used" ]] && [[ $1 == "--last-used" || $1 == "--show-last" ]]; then
|
||||||
export root; root=$(awk -F ': ' '{ print $1 }' "/tmp/$USER-rofi-pass/last_used")
|
export root; root=$(awk -F ': ' '{ print $1 }' "/tmp/$USER-rofi-pass/last_used")
|
||||||
elif [[ -n "$2" && "$1" == "--root" ]]; then
|
elif [[ -n "$2" && "$1" == "--root" ]]; then
|
||||||
export root="${2}"
|
export root="${2}"
|
||||||
elif [[ -n $root ]]; then
|
elif [[ -n $root ]]; then
|
||||||
export root="${root}"
|
export root="${root}"
|
||||||
elif [[ -n ${PASSWORD_STORE_DIR} ]]; then
|
elif [[ -n ${PASSWORD_STORE_DIR} ]]; then
|
||||||
export root=${PASSWORD_STORE_DIR}
|
export root=${PASSWORD_STORE_DIR}
|
||||||
else
|
else
|
||||||
export root="$HOME/.password-store"
|
export root="$HOME/.password-store"
|
||||||
fi
|
fi
|
||||||
export PASSWORD_STORE_DIR="${root}"
|
export PASSWORD_STORE_DIR="${root}"
|
||||||
case $1 in
|
case $1 in
|
||||||
--insert)
|
--insert)
|
||||||
insertPass
|
insertPass
|
||||||
;;
|
;;
|
||||||
--root)
|
--root)
|
||||||
mainMenu
|
mainMenu
|
||||||
;;
|
;;
|
||||||
--manage)
|
--manage)
|
||||||
manageEntry
|
manageEntry
|
||||||
;;
|
;;
|
||||||
--help)
|
--help)
|
||||||
help_msg
|
help_msg
|
||||||
;;
|
;;
|
||||||
--last-used)
|
--last-used)
|
||||||
if [[ -r "/tmp/$USER-rofi-pass/last_used" ]]; then
|
if [[ -r "/tmp/$USER-rofi-pass/last_used" ]]; then
|
||||||
entry="$(awk -F ': ' '{ print $2 }' "/tmp/$USER-rofi-pass/last_used")"
|
entry="$(awk -F ': ' '{ print $2 }' "/tmp/$USER-rofi-pass/last_used")"
|
||||||
fi
|
fi
|
||||||
mainMenu
|
mainMenu
|
||||||
;;
|
;;
|
||||||
--show-last)
|
--show-last)
|
||||||
if [[ -r "/tmp/$USER-rofi-pass/last_used" ]]; then
|
if [[ -r "/tmp/$USER-rofi-pass/last_used" ]]; then
|
||||||
selected_password="$(awk -F ': ' '{ print $2 }' "/tmp/$USER-rofi-pass/last_used")" showEntry
|
selected_password="$(awk -F ': ' '{ print $2 }' "/tmp/$USER-rofi-pass/last_used")" showEntry
|
||||||
else
|
else
|
||||||
mainMenu
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
--bmarks)
|
|
||||||
mainMenu --bmarks;
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
mainMenu
|
mainMenu
|
||||||
;;
|
fi
|
||||||
|
;;
|
||||||
|
--bmarks)
|
||||||
|
mainMenu --bmarks;
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
mainMenu
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
main "$@"
|
main "$@"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user