diff --git a/os/arch/.config/sxhkd/sxhkdrc b/os/arch/.config/sxhkd/sxhkdrc index ad20c444..c7413947 100644 --- a/os/arch/.config/sxhkd/sxhkdrc +++ b/os/arch/.config/sxhkd/sxhkdrc @@ -4,7 +4,7 @@ # terminal emulator super + ctrl + Return - urxvt + termite # scratchpad super + grave @@ -15,12 +15,9 @@ super + grave # program launcher super + space rofi -show run -# switch to desktop -super + shift + space - rofi_bspwm.sh # password manager -super + alt + space - rofi_pass.sh +super + alt + backslash + rofi-pass # make sxhkd reload its configuration files: super + Escape diff --git a/os/arch/bin/rofi_bspwm.sh b/os/arch/bin/rofi-bspwm similarity index 100% rename from os/arch/bin/rofi_bspwm.sh rename to os/arch/bin/rofi-bspwm diff --git a/os/arch/bin/rofi-pass b/os/arch/bin/rofi-pass new file mode 100755 index 00000000..586cd1f2 --- /dev/null +++ b/os/arch/bin/rofi-pass @@ -0,0 +1,32 @@ +#!/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 diff --git a/os/arch/bin/rofi_pass.sh b/os/arch/bin/rofi_pass.sh deleted file mode 100755 index 44a7ff00..00000000 --- a/os/arch/bin/rofi_pass.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -shopt -s nullglob globstar - -typeit=0 -if [[ $1 == "--type" ]]; then - typeit=1 - shift -fi - -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 - -if [[ $typeit -eq 0 ]]; then - pass show -c "$password" 2>/dev/null -else - pass show "$password" | { read -r pass; printf %s "$pass"; } | - xdotool type --clearmodifiers --file - -fi