diff options
author | Rasmus Steinke <rasi@xssn.at> | 2020-05-10 09:18:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-10 09:18:42 +0200 |
commit | b06d2226c104ae321cb749669026c66786f33d97 (patch) | |
tree | b5acb4765511dad2b35f9d456ea3d97fb68ac2b4 | |
parent | 393a02a20554299d561b07e1c0288b5bd5d88315 (diff) | |
parent | 97df0b969f5f6cea637a1e512abfb34fa400f77c (diff) | |
download | rofi-pass-b06d2226c104ae321cb749669026c66786f33d97.tar.gz |
Merge pull request #189 from darnir/xdg-base-dir
Add support for XDG Base Directory Specification
-rwxr-xr-x | rofi-pass | 27 |
1 files changed, 15 insertions, 12 deletions
@@ -17,6 +17,9 @@ _image_viewer () { feh - } +config_dir=${XDG_CONFIG_HOME:-$HOME/.config} +cache_dir=${XDG_CACHE_HOME:-$HOME/.cache} + # We expect to find these fields in pass(1)'s output URL_field='url' USERNAME_field='user' @@ -81,7 +84,7 @@ doClip () { } checkIfPass () { - printf '%s\n' "${root}: $selected_password" >| "$HOME/.cache/rofi-pass/last_used" + printf '%s\n' "${root}: $selected_password" >| "$cache_dir/rofi-pass/last_used" } @@ -89,8 +92,8 @@ autopass () { x_repeat_enabled=$(xset q | awk '/auto repeat:/ {print $3}') xset r off - rm -f "$HOME/.cache/rofi-pass/last_used" - printf '%s\n' "${root}: $selected_password" > "$HOME/.cache/rofi-pass/last_used" + rm -f "$cache_dir/rofi-pass/last_used" + printf '%s\n' "${root}: $selected_password" > "$cache_dir/rofi-pass/last_used" for word in ${stuff["$AUTOTYPE_field"]}; do case "$word" in ":tab") xdotool key Tab;; @@ -775,7 +778,7 @@ EOF get_config_file () { configs=("$ROFI_PASS_CONFIG" - "$HOME/.config/rofi-pass/config" + "$config_dir/rofi-pass/config" "/etc/rofi-pass.conf") # return the first config file with a valid path @@ -797,8 +800,8 @@ main () { [[ ! -z "$config_file" ]] && source "$config_file" # create tmp dir - if [[ ! -d "$HOME/.cache/rofi-pass" ]]; then - mkdir "$HOME/.cache/rofi-pass" + if [[ ! -d "$cache_dir/rofi-pass" ]]; then + mkdir -p "$cache_dir/rofi-pass" fi # fix keyboard layout if enabled in config @@ -817,8 +820,8 @@ main () { fi # check if alternative root directory was given on commandline - if [[ -r "$HOME/.cache/rofi-pass/last_used" ]] && [[ $1 == "--last-used" || $1 == "--show-last" ]]; then - roots=("$(awk -F ': ' '{ print $1 }' "$HOME/.cache/rofi-pass/last_used")") + if [[ -r "$cache_dir/rofi-pass/last_used" ]] && [[ $1 == "--last-used" || $1 == "--show-last" ]]; then + roots=("$(awk -F ': ' '{ print $1 }' "$cache_dir/rofi-pass/last_used")") elif [[ -n "$2" && "$1" == "--root" ]]; then custom_root=true; IFS=: read -r -a roots <<< "$2" elif [[ -n $root ]]; then @@ -843,14 +846,14 @@ main () { help_msg ;; --last-used) - if [[ -r "$HOME/.cache/rofi-pass/last_used" ]]; then - entry="$(awk -F ': ' '{ print $2 }' "$HOME/.cache/rofi-pass/last_used")" + if [[ -r "$cache_dir/rofi-pass/last_used" ]]; then + entry="$(awk -F ': ' '{ print $2 }' "$cache_dir/rofi-pass/last_used")" fi mainMenu ;; --show-last) - if [[ -r "$HOME/.cache/rofi-pass/last_used" ]]; then - selected_password="$(awk -F ': ' '{ print $2 }' "$HOME/.cache/rofi-pass/last_used")" viewEntry + if [[ -r "$cache_dir/rofi-pass/last_used" ]]; then + selected_password="$(awk -F ': ' '{ print $2 }' "$cache_dir/rofi-pass/last_used")" viewEntry else mainMenu fi |