From 7d8bece7b9272d958eeb760de861df79d58085fd Mon Sep 17 00:00:00 2001 From: = <=> Date: Fri, 29 Jan 2021 16:33:30 -0500 Subject: [PATCH] Add alternate logins --- README.md | 8 ++++++-- dwm-start | 1 + mru | 3 ++- prompt | 52 +++++++++++++++++++++++++++++++--------------------- 4 files changed, 40 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 358ceeb..4d5edeb 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,10 @@ most functionality is accessible from launch and action only - You may want to bind Mod4+a to `launch action` and Mod4+g to `prompt launch` - Some prompts like `search package` will infer with their default operation when the string entered is an invalid selection +- the password functions assume that logins for the same services are all + stored in the same file, with each account's information seperated by an + empty line. Each line containing a username begins with 'username:', each + line containing a password is the first line of it's section. ## mru Used for storing file paths and their modification times in ~/.cache/mru/. @@ -92,7 +96,6 @@ exists. #### TODO - Finish vpn and networking stuff after ini script is finished, then make sure -- Add ddg search prompt - setup pass - variables to the script to make assumed paths easier to change - emoji select to clipboard @@ -101,9 +104,10 @@ exists. - Make password prompts green - Figure out range selecting for parsing passwords - Figure out using dmenu instead of gnome key prompt (pinentry) -- Consider entr in dwm-start for watching files +what?- Consider entr in dwm-start for watching files - change xdg text/plain opener to use vim and st if not in terminal - unicode character insertion - finish editing text-opener change prompt icon to nerd icon - select window with wmctrl +- prompt for copying files to laptop diff --git a/dwm-start b/dwm-start index aa16272..be2b8fb 100755 --- a/dwm-start +++ b/dwm-start @@ -3,6 +3,7 @@ setxkbmap -option caps:swapescape picom -b ~/.fehbg xbindkeys -f $HOME/Backups/configs/xbindkeysrc +mru update & # relaunch DWM if the binary changes, otherwise bail csum=$(sha1sum $(which dwm.winkey)) diff --git a/mru b/mru index 82dc841..752c5fc 100755 --- a/mru +++ b/mru @@ -84,7 +84,8 @@ insert() { fi fi - if [ ! -z $file_path ]; then + if [ ! -z "$file_path" ]; then + echo "second sed starts" sed -i "0,\|.*\t.*\t$file_path|d" $XDG_CACHE_HOME/mru/$cache_name fi diff --git a/prompt b/prompt index b27c15a..a3688b4 100755 --- a/prompt +++ b/prompt @@ -136,7 +136,7 @@ package() { editor() { #handle spacing in filenames bug - file=$(mru list | dmenu -i -l 10 -p 'edit what?') + file=$(mru list | dmenu -i -l 10 -p 'edit file') if [ -z "$file" ]; then exit; fi first=$(printf "$file" | head -n1 -) d=$(dirname "$first") @@ -146,7 +146,7 @@ editor() { } opener() { - mru list | dmenu -i -l 20 -p 'open' | while read f; do mru insert "$f" & xdg-open $f; done + mru list | dmenu -i -l 20 -p 'open' | while read f; do xdg-open "$f"; done } screenshot() { @@ -272,10 +272,17 @@ cmd_clip() { printf "%s" "$value" | xclip -selection clipboard } -username() { - account=$(find ~/.password-store/[!\.]* -type f | +sel_account() { + account=$( + find ~/.password-store/[!\.]* -type f | sed -e "s:$HOME/.password-store/::" -e "s:\.gpg::" | - dmenu -p 'account') + dmenu -p 'account' + ) + if [ -z "$account" ]; then exit; fi +} + +username() { + account=$(sel_account) if [ -z "$account" ]; then exit; fi name=$(pass show "$account" | sed -n -e "s/^username: //p" | dmenu -p 'which username' | xclip -f -selection clipboard) @@ -284,6 +291,8 @@ username() { } password() { + rm prompt-login-* + touch /tmp/prompt-login-$$ account=$(find ~/.password-store/[!\.]* -type f | sed -e "s:$HOME/.password-store/::" -e "s:\.gpg::" | dmenu -p 'which service') @@ -293,31 +302,27 @@ password() { } other_password() { - account=$(find ~/.password-store/[!\.]* -type f | - sed -e "s:$HOME/.password-store/::" -e "s:\.gpg::" | - dmenu -p 'service') - if [ -z "$account" ]; then exit; fi + account=$(sel_account) name=$(pass show "$account" | sed -n -e "s/^username: //p" | dmenu -p 'which user password') if [ -z "$name" ]; then exit; fi + pass show $account | sed "/^$/,/^username: $name/ { /^$/n }" | head -n1 | tr -d '\n' | xclip -selection clipboard + notify-send -u low -t 2000 "password copied" "$account: $name" - - #figure out range selections - sed -n -e "" } show_password() { - ls + account=$(sel_account) + info=$(pass show "$account") + st -e sh -lc "printf '$info' | less" } edit_password() { - account=$(find ~/.password-store/[!\.]* -type f | - sed -e "s:$HOME/.password-store/::" -e "s:\.gpg::" | - dmenu -p 'which service') - if [ -z "$account" ]; then exit; fi - error=$(st -e pass edit "$account" 2>&1) - if [ -n "$error" ]; then notify-send -u low -t 3000 "password edit error" "$error"; fi -} + account=$(sel_account) + if [ -z "$account" ]; then exit; fi + error=$(st -e pass edit "$account" 2>&1) + if [ -n "$error" ]; then notify-send -u low -t 3000 "password edit error" "$error"; fi + } chooser() { f=$(mru list | dmenu -i -l 20 -p 'choose file') @@ -327,8 +332,12 @@ chooser() { $c "$f" } +vpn() { + ls +} + case $1 in - launch) launch;; + launch ) launch;; action) action;; cmd) cmd;; cmd_clip) cmd_clip;; @@ -336,5 +345,6 @@ case $1 in search) do_search;; open) opener;; choose) chooser;; + vpn) vpn;; *) printf "Invalid argument";; esac