summaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-11-18 19:31:51 +0100
committerThomas Voss <mail@thomasvoss.com> 2023-11-18 19:31:51 +0100
commitca2d328950a1d5c031c855ec32dc09eeb337ae65 (patch)
tree2e00d4427bf3b39e644f3b90f6ae438990632706 /.local
parentc65e9ded7f24b2b137c1151a392abb06dc58e1c6 (diff)
vlt: Codestyle fixes
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/vlt144
1 files changed, 72 insertions, 72 deletions
diff --git a/.local/bin/vlt b/.local/bin/vlt
index fe72cd2..72ec397 100755
--- a/.local/bin/vlt
+++ b/.local/bin/vlt
@@ -41,7 +41,7 @@ prompt()
printf '%s ' "$1"
read -r s
else
- s="`zenity --title=zenity --entry --text="$1"`"
+ s="$(zenity --title=zenity --entry --text="$1")"
fi
sanitize "$s"
}
@@ -58,7 +58,7 @@ xprompt()
trap - INT
echo
else
- s="`zenity --title=zenity --password --text="$1"`"
+ s="$(zenity --title=zenity --password --text="$1")"
fi
sanitize "$s"
}
@@ -80,18 +80,18 @@ add()
esac
done
- readonly data="`enchive extract <"$VAULT"`"
+ readonly data="$(enchive extract <"$VAULT")"
- c="`xecho "$data" | jq -r 'keys | .[]' | osel`"
+ c="$(xecho "$data" | jq -r 'keys | .[]' | osel)"
prompt 'Password name:'
n="$s"
xecho "$data" \
- | jq -e --arg c "$c" --arg n "$n" '.[$c] | has($n) | not' >/dev/null || {
- xnotify 'Failed To Add Password' "The password ‘$n’ already exists"
- exit 1
- }
+ | jq -e --arg c "$c" --arg n "$n" '.[$c] | has($n) | not' >/dev/null || {
+ xnotify 'Failed To Add Password' "The password ‘$n’ already exists"
+ exit 1
+ }
if [ "$VAULT_2FA" = "$c" ]
then
@@ -100,25 +100,25 @@ add()
prompt 'Period:'
xecho "$data" \
- | jq --arg c "$c" \
- --arg n "$n" \
- --arg s "$k" \
- --arg d "$d" \
- --arg p "$s" \
- '.[$c] += {($n): {
- "secret": $s,
- "digits": ($d | tonumber),
- "period": ($p | tonumber)
- }}' \
- | enchive archive >"$VAULT"
+ | jq --arg c "$c" \
+ --arg n "$n" \
+ --arg s "$k" \
+ --arg d "$d" \
+ --arg p "$s" \
+ '.[$c] += {($n): {
+ "secret": $s,
+ "digits": ($d | tonumber),
+ "period": ($p | tonumber)
+ }}' \
+ | enchive archive >"$VAULT"
[ ! -t 2 ] && xnotify '2FA Key Added' \
"The 2FA key ‘$n’ was added with the digit length ‘$d’ and period ‘$p’"
else
xprompt 'Password:'
xecho "$data" \
- | jq --arg c "$c" --arg n "$n" --arg s "$s" '.[$c] += {($n): $s}' \
- | enchive archive >"$VAULT"
+ | jq --arg c "$c" --arg n "$n" --arg s "$s" '.[$c] += {($n): $s}' \
+ | enchive archive >"$VAULT"
[ ! -t 2 ] && xnotify 'Password Added' \
"The password ‘$n’ was added to the category ‘$c’"
fi
@@ -126,7 +126,7 @@ add()
add_c()
{
- readonly data="`enchive extract <"$VAULT"`"
+ readonly data="$(enchive extract <"$VAULT")"
prompt 'Category to create:'
@@ -136,22 +136,22 @@ add_c()
}
xecho "$data" \
- | jq --arg s "$s" '. + {($s): {}}' \
- | enchive archive >"$VAULT"
+ | jq --arg s "$s" '. + {($s): {}}' \
+ | enchive archive >"$VAULT"
[ ! -t 2 ] && \
xnotify 'Category Created' "The password category ‘$s’ was created"
}
get()
{
- readonly data="`enchive extract <"$VAULT"`"
+ readonly data="$(enchive extract <"$VAULT")"
- c="`xecho "$data" | jq -r 'keys | .[]' | osel`"
- o="`xecho "$data" | jq -r --arg c "$c" '.[$c] | keys | .[]' | osel`"
+ c="$(xecho "$data" | jq -r 'keys | .[]' | osel)"
+ o="$(xecho "$data" | jq -r --arg c "$c" '.[$c] | keys | .[]' | osel)"
xecho "$data" | if [ "$VAULT_2FA" = "$c" ]
then
- eval "`jq -r --arg c "$c" --arg o "$o" '
+ eval "$(jq -r --arg c "$c" --arg o "$o" '
.[$c]
| .[$o]
| "totp -d"
@@ -160,17 +160,17 @@ get()
+ (.period | tostring)
+ " "
+ .secret
- '`" \
- | wl-copy -no \
- && [ ! -t 2 ] \
- && xnotify '2FA Code Copied To The Clipboard' \
- "The 2FA code for ‘$o’ was copied to the clipboard"
+ ')" \
+ | wl-copy -no \
+ && [ ! -t 2 ] \
+ && xnotify '2FA Code Copied To The Clipboard' \
+ "The 2FA code for ‘$o’ was copied to the clipboard"
else
jq -r --arg c "$c" --arg o "$o" '.[$c] | .[$o]' \
- | wl-copy -no \
- && [ ! -t 2 ] \
- && xnotify 'Password Copied To The Clipboard' \
- "The password for ‘$o’ was copied to the clipboard"
+ | wl-copy -no \
+ && [ ! -t 2 ] \
+ && xnotify 'Password Copied To The Clipboard' \
+ "The password for ‘$o’ was copied to the clipboard"
fi
}
@@ -191,33 +191,33 @@ rm_()
esac
done
- readonly data="`enchive extract <"$VAULT"`"
+ readonly data="$(enchive extract <"$VAULT")"
- c="`xecho "$data" | jq -r 'keys | .[]' | osel`"
- n="`xecho "$data" | jq -r --arg c "$c" '.[$c] | keys | .[]' | osel`"
+ c="$(xecho "$data" | jq -r 'keys | .[]' | osel)"
+ n="$(xecho "$data" | jq -r --arg c "$c" '.[$c] | keys | .[]' | osel)"
xecho "$data" \
- | jq --arg c "$c" --arg n "$n" 'del(.[$c] | .[$n])' \
- | enchive archive >"$VAULT"
+ | jq --arg c "$c" --arg n "$n" 'del(.[$c] | .[$n])' \
+ | enchive archive >"$VAULT"
[ ! -t 2 ] && xnotify 'Removed Password' \
"The password ‘$n’ was removed from the category ‘$c’"
}
rm_c()
{
- readonly data="`enchive extract <"$VAULT"`"
+ readonly data="$(enchive extract <"$VAULT")"
- c="`xecho "$data" | jq -r 'keys | .[]' | osel`"
+ c="$(xecho "$data" | jq -r 'keys | .[]' | osel)"
xecho "$data" \
- | jq -e --arg c "$c" '.[$c] | length == 0' >/dev/null || {
- xnotify 'Failed To Remove Category' "The category ‘$c’ is not empty"
- exit 1
- }
+ | jq -e --arg c "$c" '.[$c] | length == 0' >/dev/null || {
+ xnotify 'Failed To Remove Category' "The category ‘$c’ is not empty"
+ exit 1
+ }
xecho "$data" \
- | jq --arg c "$c" 'del(.[$c])' \
- | enchive archive >"$VAULT"
+ | jq --arg c "$c" 'del(.[$c])' \
+ | enchive archive >"$VAULT"
[ ! -t 2 ] && xnotify 'Removed Category' "The category ‘$c’ was removed"
}
@@ -238,10 +238,10 @@ edit()
esac
done
- readonly data="`enchive extract <"$VAULT"`"
+ readonly data="$(enchive extract <"$VAULT")"
- c="`xecho "$data" | jq -r 'keys | .[]' | osel`"
- n="`xecho "$data" | jq -r --arg c "$c" '.[$c] | keys | .[]' | osel`"
+ c="$(xecho "$data" | jq -r 'keys | .[]' | osel)"
+ n="$(xecho "$data" | jq -r --arg c "$c" '.[$c] | keys | .[]' | osel)"
if [ "$VAULT_2FA" = "$c" ]
then
@@ -250,24 +250,24 @@ edit()
prompt 'Period:'
xecho "$data" \
- | jq --arg c "$c" \
- --arg n "$n" \
- --arg s "$k" \
- --arg d "$d" \
- --arg p "$s" \
- '.[$c] += {($n): {
- "secret": $s,
- "digits": ($d | tonumber),
- "period": ($p | tonumber)
- }}' \
- | enchive archive >"$VAULT"
+ | jq --arg c "$c" \
+ --arg n "$n" \
+ --arg s "$k" \
+ --arg d "$d" \
+ --arg p "$s" \
+ '.[$c] += {($n): {
+ "secret": $s,
+ "digits": ($d | tonumber),
+ "period": ($p | tonumber)
+ }}' \
+ | enchive archive >"$VAULT"
[ ! -t 2 ] && xnotify '2FA Key Added' \
"The 2FA key ‘$n’ was added with the digit length ‘$d’ and period ‘$p’"
else
xprompt 'Password:'
xecho "$data" \
- | jq --arg c "$c" --arg n "$n" --arg s "$s" '.[$c] += {($n): $s}' \
- | enchive archive >"$VAULT"
+ | jq --arg c "$c" --arg n "$n" --arg s "$s" '.[$c] += {($n): $s}' \
+ | enchive archive >"$VAULT"
[ ! -t 2 ] && xnotify 'Password Edit' \
"The password ‘$n’ in the category ‘$c’ was changed"
fi
@@ -275,14 +275,14 @@ edit()
edit_c()
{
- readonly data="`enchive extract <"$VAULT"`"
+ readonly data="$(enchive extract <"$VAULT")"
- c="`xecho "$data" | jq -r 'keys | .[]' | osel`"
+ c="$(xecho "$data" | jq -r 'keys | .[]' | osel)"
prompt 'Category name:'
xecho "$data" \
- | jq --arg o "$c" --arg n "$s" \
- 'with_entries(if .key == $o then .key = $n else . end)' \
- | enchive archive >"$VAULT"
+ | jq --arg o "$c" --arg n "$s" \
+ 'with_entries(if .key == $o then .key = $n else . end)' \
+ | enchive archive >"$VAULT"
[ ! -t 2 ] && xnotify 'Category Edit' "The category ‘$c’ was renamed"
}
@@ -290,7 +290,7 @@ raw()
{
shift
enchive extract <"$VAULT" \
- | jq --arg c "$1" --arg n "$2" -r '.[$c] | .[$n]'
+ | jq --arg c "$1" --arg n "$2" -r '.[$c] | .[$n]'
}
: ${VAULT_2FA:="2fa"}