write temporary files to ~/.cache

This commit is contained in:
Rasmus Steinke 2016-07-16 16:59:53 +02:00
parent b6dcf56e9a
commit cd8e18670e

View File

@ -33,8 +33,9 @@ checkIfPass () {
elif [[ $selected_password == "---" ]]; then
mainMenu;
else
rm -f "/tmp/$USER-rofi-pass/last_used"
echo "${root}: $selected_password" > "/tmp/$USER-rofi-pass/last_used"
rm -f "$HOME/.cache/rofi-pass/last_used"
echo "${root}: $selected_password" > "$HOME/.cache/rofi-pass/last_used"
chmod 600 "$HOME/.cache/rofi-pass/last_used"
fi
}
@ -45,8 +46,9 @@ autopass () {
elif [[ ${selected_password} == "---" ]]; then
mainMenu;
else
rm -f "/tmp/$USER-rofi-pass/last_used"
echo "${root}: $selected_password" > "/tmp/$USER-rofi-pass/last_used"
rm -f "$HOME/.cache/rofi-pass/last_used"
echo "${root}: $selected_password" > "$HOME/.cache/rofi-pass/last_used"
chmod 600 "$HOME/.cache/rofi-pass/last_used"
if [[ -z "${stuff["$AUTOTYPE_field"]}" ]]; then
if [[ "${stuff["${USERNAME_field}"]}" ]]; then
echo -n "${stuff["${USERNAME_field}"]}" | xdotool type --clearmodifiers --file -
@ -498,8 +500,8 @@ if [[ -f "$HOME/.config/rofi-pass/config" ]]; then
fi
# create tmp dir
if [[ ! -d /tmp/$USER-rofi-pass ]]; then
mkdir "/tmp/$USER-rofi-pass"
if [[ ! -d $HOME/.cache/rofi-pass ]]; then
mkdir "$HOME/.cache/rofi-pass"
fi
# set help color
@ -517,8 +519,8 @@ if [[ -z ${count} ]]; then
fi
# check if alternative root directory was given on commandline
if [[ -r "/tmp/$USER-rofi-pass/last_used" ]] && [[ $1 == "--last-used" || $1 == "--show-last" ]]; then
export root; root=$(awk -F ': ' '{ print $1 }' "/tmp/$USER-rofi-pass/last_used")
if [[ -r "$HOME/.cache/rofi-pass/last_used" ]] && [[ $1 == "--last-used" || $1 == "--show-last" ]]; then
export root; root=$(awk -F ': ' '{ print $1 }' "$HOME/.cache/rofi-pass/last_used")
elif [[ -n "$2" && "$1" == "--root" ]]; then
export root="${2}"
elif [[ -n $root ]]; then
@ -543,14 +545,14 @@ export PASSWORD_STORE_DIR="${root}"
help_msg
;;
--last-used)
if [[ -r "/tmp/$USER-rofi-pass/last_used" ]]; then
entry="$(awk -F ': ' '{ print $2 }' "/tmp/$USER-rofi-pass/last_used")"
if [[ -r "$HOME/.cache/rofi-pass/last_used" ]]; then
entry="$(awk -F ': ' '{ print $2 }' "$HOME/.cache/rofi-pass/last_used")"
fi
mainMenu
;;
--show-last)
if [[ -r "/tmp/$USER-rofi-pass/last_used" ]]; then
selected_password="$(awk -F ': ' '{ print $2 }' "/tmp/$USER-rofi-pass/last_used")" showEntry
if [[ -r "$HOME/.cache/rofi-pass/last_used" ]]; then
selected_password="$(awk -F ': ' '{ print $2 }' "$HOME/.cache/rofi-pass/last_used")" showEntry
else
mainMenu
fi