summaryrefslogtreecommitdiff
path: root/scripts/.local/bin
diff options
context:
space:
mode:
authorivan-boikov <ik.boikov.public@protonmail.com>2023-01-30 23:03:25 +0100
committerivan-boikov <ik.boikov.public@protonmail.com>2023-01-30 23:03:25 +0100
commit3a24e908616f96a728a9524d36d3ec6687736eb1 (patch)
treea7655641a79999de7e6ebb4377bb4973bd8665b7 /scripts/.local/bin
parentc70826d3042c0821051cd28d305251153733a91c (diff)
1
Diffstat (limited to 'scripts/.local/bin')
-rwxr-xr-xscripts/.local/bin/dpass31
-rwxr-xr-xscripts/.local/bin/getbib8
-rwxr-xr-xscripts/.local/bin/protonmail-bridge3
3 files changed, 29 insertions, 13 deletions
diff --git a/scripts/.local/bin/dpass b/scripts/.local/bin/dpass
index 53e9129..a3f4e72 100755
--- a/scripts/.local/bin/dpass
+++ b/scripts/.local/bin/dpass
@@ -18,15 +18,15 @@ fi
if [[ $1 == "--type" ]]; then
if [[ -n $WAYLAND_DISPLAY ]]; then
- xdotool="ydotool type --file -"
+ xdotool=("ydotool" "type" "--file" "-")
elif [[ -n $DISPLAY ]]; then
- xdotool="xdotool type --clearmodifiers --file -"
+ xdotool=("xdotool" "type" "--clearmodifiers" "--file" "-")
else
echo "Error: No Wayland or X11 display detected" >&2
exit 1
fi
#output_method=("{ IFS= read -r pass; printf %s $pass; } | $xdotool")
- output_method=("$xdotool")
+ output_method=("${xdotool[@]}")
action_descr="typed"
shift
fi
@@ -58,7 +58,7 @@ if [[ ! ${password_files[*]} =~ "${password_file}" ]]; then
exit 1
fi
-action=$(printf "password\nlogin\ninfo" | "$dmenu" -l 3)
+action=$(printf "password\nlogin\nOTP\ninfo" | "$dmenu" -l 4)
case $action in
login)
login=$(pass show "$password_file" | sed -n -e '/^login:/p' | awk '{print $2}')
@@ -66,18 +66,33 @@ case $action in
notify-send -u critical "No login for \"$password_file\" was found"
exit 1
fi
- echo "$login" | $output_method
+ printf "%s" "$login" | "${output_method[@]}"
if [[ -n $action_descr ]]; then
notify-send "Login for \"$password_file\" was $action_descr"
fi
;;
password)
- pass show "$password_file" | head -n 1 | $output_method
- #pass show -c "$password" 2>/dev/null
+ password=$(pass show "$password_file" | head -n 1)
+ if [[ -z $password ]]; then
+ notify-send -u critical "No password for \"$password_file\" was found"
+ exit 1
+ fi
+ printf "%s" "$password" | "${output_method[@]}"
if [[ -n $action_descr ]]; then
notify-send "Password for \"$password_file\" was $action_descr"
fi
;;
+ OTP)
+ otp=$(pass otp "$password_file")
+ if [[ -z $otp ]]; then
+ notify-send -u critical "No OTP for \"$password_file\" was found"
+ exit 1
+ fi
+ printf "%s" "$otp" | "${output_method[@]}"
+ if [[ -n $action_descr ]]; then
+ notify-send "OTP for \"$password_file\" was $action_descr"
+ fi
+ ;;
info)
data="$(pass show "$password_file" | tail -n +2 | sed '/login\:/d')"
if [[ -z $data ]]; then
@@ -93,7 +108,7 @@ case $action in
if [[ $do_trim == "Yes" ]]; then
data=$(echo "$data" | cut -f 2- -d ' ')
fi
- echo "$data" | $output_method
+ printf "%s" "$data" | "${output_method[@]}"
if [[ -n $action_descr ]]; then
notify-send "Data for $password_file was $action_descr"
fi
diff --git a/scripts/.local/bin/getbib b/scripts/.local/bin/getbib
index 3c6d79d..273f903 100755
--- a/scripts/.local/bin/getbib
+++ b/scripts/.local/bin/getbib
@@ -5,8 +5,10 @@ if [ -f "$1" ]; then
# Try to get DOI from pdfinfo or pdftotext output.
doi=$(pdfinfo "$1" | grep -io "doi:.*") ||
doi=$(pdfinfo "$1" | grep -io "Digital Object Identifier.*") ||
- doi=$(pdftotext "$1" 2>/dev/null - | grep -io "doi:.*" -m 1) ||
- doi=$(pdftotext "$1" 2>/dev/null - | grep -io "Digital Object Identifier.*" -m 1) ||
+ doi=$(pdftotext "$1" - | grep -io "doi:.*" -m 1) ||
+ doi=$(pdftotext "$1" - | grep -io "DOI:.*" -m 1) ||
+ doi=$(pdftotext "$1" - | grep -io "doi.org/.*" -m 1) ||
+ doi=$(pdftotext "$1" - | grep -io "Digital Object Identifier.*" -m 1) ||
exit 1
else
doi="$1"
@@ -20,4 +22,4 @@ echo "Detected DOI: $doi"
# Check crossref.org for the bib citation.
curl -s "http://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\\n"
-wget "https://doi.org/$doi"
+#wget "https://doi.org/$doi"
diff --git a/scripts/.local/bin/protonmail-bridge b/scripts/.local/bin/protonmail-bridge
index 9114d81..e45c0a1 100755
--- a/scripts/.local/bin/protonmail-bridge
+++ b/scripts/.local/bin/protonmail-bridge
@@ -5,8 +5,7 @@
name="protonmail-bridge daemon"
description=""
-#command=/usr/bin/protonmail-bridge
-command=/home/protonmail/proton-bridge
+command=/usr/bin/proton-mail-bridge
#command_args="${protonmail-bridge_args}"
command_args="--no-window --noninteractive"
command_user="protonmail:protonmail"