-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword-manager.bash
More file actions
executable file
·29 lines (26 loc) · 1.05 KB
/
Copy pathpassword-manager.bash
File metadata and controls
executable file
·29 lines (26 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
get_password() {
selection=$(cat $HOME/.local/share/secret/passwords | awk 'NR % 2 {print} !(NR % 2) && /pattern/ {print}' .local/share/secret/passwords | fuzzel -d | awk -F "." '{print $1}')
if [[ -z $selection ]]; then
exit 0
fi
awk "NR==$(($selection*2))" .local/share/secret/passwords | xargs -I % wtype %
}
new_password() {
input=$(zenity --entry --text="New password entry. Use the following format: \n <Name of service>|<password>")
if [[ -z $input ]]; then
exit 0
fi
newName=$(echo $input | awk -F "|" '{print $1}')
newPassword=$(echo $input | awk -F "|" '{print $2}')
numberLastEntry=$(tail -2 .local/share/secret/passwords | head -1 | awk -F "." '{print $1}')
printf "$(($numberLastEntry+1)). $newName\n$newPassword" >> $HOME/.local/share/secret/passwords
notify-send -i "$HOME/.config/hypr/scripts/icon0-vector-493-01.png" "New password entry" "Password entry added to passwords file"
}
if [[ "$1" == "--new" ]]; then
new_password
elif [[ "$1" == "--get" ]]; then
get_password
else
echo "Needs a valid argument: --get or --new"
fi