os/arch/bin: -rofi-bspwm -rofi-pass +dpass
This commit is contained in:
		
							parent
							
								
									8a3162d983
								
							
						
					
					
						commit
						f01a65aa30
					
				
							
								
								
									
										26
									
								
								os/arch/bin/dpass
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										26
									
								
								os/arch/bin/dpass
									
									
									
									
									
										Executable file
									
								
							| 
						 | 
					@ -0,0 +1,26 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					shopt -s nullglob globstar
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					prefix=${PASSWORD_STORE_DIR-~/.password-store}
 | 
				
			||||||
 | 
					password_files=( "$prefix"/**/*.gpg  )
 | 
				
			||||||
 | 
					password_files=( "${password_files[@]#"$prefix"/}"  )
 | 
				
			||||||
 | 
					password_files=( "${password_files[@]%.gpg}" )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					entry=$(printf "%s\n" "${password_files[@]}" | rofi -dmenu -p pass: "$@")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[[ -n $entry ]] || exit
 | 
				
			||||||
 | 
					out=$(pass show "$entry")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[[ $out ]] || exit
 | 
				
			||||||
 | 
					fields=$(echo "$out" | cut -d: -f1 | tail -n +2)
 | 
				
			||||||
 | 
					field=$(printf "password\n%s\n" "${fields[@]}" | rofi -dmenu -p pass:field:)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					case "$field" in
 | 
				
			||||||
 | 
					    password)
 | 
				
			||||||
 | 
					        pass -c "$entry"
 | 
				
			||||||
 | 
					        ;;
 | 
				
			||||||
 | 
					    *)
 | 
				
			||||||
 | 
					        echo "$out" | grep "^${field}:" | awk '{print $2}' | xclip -selection clipboard -in
 | 
				
			||||||
 | 
					        ;;
 | 
				
			||||||
 | 
					esac
 | 
				
			||||||
| 
						 | 
					@ -1,10 +0,0 @@
 | 
				
			||||||
#!/usr/bin/env bash
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
shopt -s nullglob globstar
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
desktops=($(cat /tmp/bspwm-monitor-*))
 | 
					 | 
				
			||||||
desktop=$(printf '%s\n' "${desktops[@]}" | rofi -dmenu -p bspwm: "$@")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[[ -n $desktop  ]] || exit
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
bspc desktop -f $desktop
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,32 +0,0 @@
 | 
				
			||||||
#!/usr/bin/env bash
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
shopt -s nullglob globstar
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
prefix=${PASSWORD_STORE_DIR-~/.password-store}
 | 
					 | 
				
			||||||
password_files=( "$prefix"/**/*.gpg  )
 | 
					 | 
				
			||||||
password_files=( "${password_files[@]#"$prefix"/}"  )
 | 
					 | 
				
			||||||
password_files=( "${password_files[@]%.gpg}"  )
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
password=$(printf "%s\n" "${password_files[@]}" | rofi -dmenu -p pass: "$@")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[[ -n $password  ]] || exit
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
for browser in firefox chromium
 | 
					 | 
				
			||||||
do
 | 
					 | 
				
			||||||
    wid=$(xdotool search --onlyvisible --name "$browser")
 | 
					 | 
				
			||||||
    [[ $wid ]] && break
 | 
					 | 
				
			||||||
done
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# If browser is in focus, type it in
 | 
					 | 
				
			||||||
if [[ $wid = $(xdotool getwindowfocus) ]]
 | 
					 | 
				
			||||||
then
 | 
					 | 
				
			||||||
    data="$(pass show "$password")"
 | 
					 | 
				
			||||||
    pass="$(echo "$data" | head -1)"
 | 
					 | 
				
			||||||
    login="$(echo "$data" | grep "^login:" | awk '{print $2}')"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    xdotool type --clearmodifiers "$login"
 | 
					 | 
				
			||||||
    xdotool key Tab
 | 
					 | 
				
			||||||
    xdotool type --clearmodifiers "$pass"
 | 
					 | 
				
			||||||
else
 | 
					 | 
				
			||||||
    pass show -c "$password" 2>/dev/null
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
		Loading…
	
		Reference in a new issue