使用してパスとrofiは空想パスワードマネージャを取得する


私はパスを私の主なパスワードマネージャとして使用しています.これは完全にCLIベースのバージョンコントロールとGPPG 2暗号化されます.しかし、CLIで使用するパスは、パスワードを要求しているブラウザや他のアプリケーションを持っているとき、何の意味もありません.パスとautotype機能のより便利な使用法を得るために、我々は少し創造的でなければなりません.
Rofiは、Windowsのスイッチャとは、高設定のアプリケーションランチャーです.私は両方のスクリプトを組み合わせた.オートタイプ機能を取得するにはxdotool すべてのLinuxマシンに標準をインストールする必要があります.
に依存するrofi.conf あなたのシステムで完全に統合されている素敵なパスワードマネージャを取得します.

#!/bin/bash

shopt -s nullglob globstar

# switch for autotyping
typeit=0
if [[ $1 == "--type" ]]; then
    typeit=1
    shift
fi

# get all the saved password files
prefix=${PASSWORD_STORE_DIR-~/.password-store}
password_files=( "$prefix"/**/*.gpg )
password_files=( "${password_files[@]#"$prefix"/}" )
password_files=( "${password_files[@]%.gpg}" )

# shows a list of all password files and saved the selected one in a variable
password=$(printf '%s\n' "${password_files[@]}" | rofi -dmenu "$@" -theme ~/dotfiles/i3/rofi.rasi)
[[ -n $password ]] || exit


# pass -c copied the password in clipboard. The additional output from pass is piped in to /dev/null 
if [[ $typeit -eq 0 ]]; then
    pass show -c "$password" | head -n1  2>/dev/null
else
    # If i want to use autotype i save the user name and the password in to a variable 
    # the actual password files are simple text file. 
    # The password has to be on the first line,
    # because if you using `pass -i` the first line will be replaced with a new password

    passw=$(pass show $password | head -n1 )
    uname=$(pass show $password | tail -n1 )
    # xdotool types the username on the active spot (cli or inputfield from a browser)
    xdotool type "$uname"
    # type a TAB (for moving forward in browser input fields)
    xdotool key Tab
    # type the password in the active input
    xdotool type "$passw"
    xdotool key Tab
fi
私はウィンドウマネージャとしてi 3 wmを使用しているので、簡単に私のパスワードマネージャをアクティブにするための短いキーを使用することができます.
bindsym $mod+p mode "password"
mode "password" {
    bindsym p exec "/home/maren/dotfiles/scripts/passScript.sh"
    bindsym t exec "/home/maren/dotfiles/scripts/passScript.sh --type"

    bindsym Return mode "default"
    bindsym Escape mode "default"
    bindsym $mod+r mode "default"
}