scripts

Scripts
git clone git://git.wimdupont.com/scripts.git
Log | Files | Refs | LICENSE

commit 50d7d9a8214dd4e1d268800d48aa8364a831b95e
parent 1ccd7a9ee944f09a3633c6bdbf5417fc6d07dd71
Author: Wim Dupont <wim@wimdupont.com>
Date:   Sat, 30 Jul 2022 20:22:55 +0200

ignore case in dmenu scripts and updated encr

Diffstat:
MREADME.adoc | 3++-
Mbin/encr | 30+++++++++++++++++++++++++++---
Mbin/mpvd | 8++++----
Mbin/otp | 2+-
Mbin/pwu | 4++--
Mbin/radio | 2+-
6 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/README.adoc b/README.adoc @@ -20,7 +20,8 @@ Decrypts a GPG encrypted TAR file. == ./bin/encr -Archives a given file or directory as a TAR file and encrypts it with GPG using symmetric encryption. +Archives a given file or directory as a TAR file and encrypts it with GPG using symmetric or asymmetric encryption. By default it uses symmetric encryption and looks for encrypted +file "~/sym-pwd.gpg" to use its content as password. == ./bin/mpvd diff --git a/bin/encr b/bin/encr @@ -1,5 +1,20 @@ #!/bin/bash +#Encrypted file with default symmetric password +sym_pwd=$HOME/.sym-pwd.gpg + +disable_default_pwd=0 +asymmetric=0 + +while getopts "da" arg; do + case $arg in + d) disable_default_pwd=1;; + a) asymmetric=1;; + esac +done + +shift $((OPTIND-1)) + file=$1 #Removes last occurence of "/", gets added when using tab autocomplete @@ -9,7 +24,16 @@ fi tar -cf "$file".tar "$file" -gpg -c --no-symkey-cache --cipher-algo AES256 "$file".tar - -rm -v "$file".tar +#Ensures deletion of unencrypted tar file on exit +trap 'rm -v "$file".tar' EXIT +if [ $asymmetric -eq 0 ]; then + if [ $disable_default_pwd -eq 0 ] && [ -f "$sym_pwd" ]; then + pwd=$(gpg --decrypt "${sym_pwd}" 2>/dev/null) + gpg --passphrase "${pwd}" --batch --yes -c --no-symkey-cache --cipher-algo AES256 "$file".tar + else + gpg -c --no-symkey-cache --cipher-algo AES256 "$file".tar + fi +else + gpg -e "$file".tar +fi diff --git a/bin/mpvd b/bin/mpvd @@ -21,11 +21,11 @@ done songdirs=( "${songdirs[@]#"$prefix"/}" ) songdirs=( "${songdirs[@]%/}" ) -songdir=$(printf '%s\n' "${songdirs[@]}" | "$dmenu" -fn "$font" -l "$lines" "$@") +songdir=$(printf '%s\n' "${songdirs[@]}" | "$dmenu" -fn "$font" -i -l "$lines" "$@") [[ -n $songdir ]] || exit -playsongdir=$(printf "no\nyes" | "$dmenu" -fn "$font" "$@" -p "Play full directory?") +playsongdir=$(printf "no\nyes" | "$dmenu" -fn "$font" -i "$@" -p "Play full directory?") [[ -n $playsongdir ]] || exit @@ -34,10 +34,10 @@ if [[ "$playsongdir" == no ]]; then songdirs=( "$prefix"/**/*) songdirs=( "${songdirs[@]#"$prefix"/}" ) songdirs=( "${songdirs[@]%}" ) - songdir=$(printf '%s\n' "${songdirs[@]}" | "$dmenu" -fn "$font" -l "$lines" "$@") + songdir=$(printf '%s\n' "${songdirs[@]}" | "$dmenu" -fn "$font" -i -l "$lines" "$@") [[ -n $songdir ]] || exit else - random=$(printf "no\nyes" | "$dmenu" -fn "$font" "$@" -p "Shuffle?") + random=$(printf "no\nyes" | "$dmenu" -fn "$font" -i "$@" -p "Shuffle?") [[ -n $random ]] || exit diff --git a/bin/otp b/bin/otp @@ -26,7 +26,7 @@ password_files=( "$prefix"/otp/**/*.gpg ) password_files=( "${password_files[@]#"$prefix"/}" ) password_files=( "${password_files[@]%.gpg}" ) -password=$(printf '%s\n' "${password_files[@]}" | "$dmenu" -fn "$font" "$@") +password=$(printf '%s\n' "${password_files[@]}" | "$dmenu" -fn "$font" -i "$@") [[ -n $password ]] || exit diff --git a/bin/pwu b/bin/pwu @@ -26,7 +26,7 @@ password_files=( "$prefix"/**/*.gpg ) password_files=( "${password_files[@]#"$prefix"/}" ) password_files=( "${password_files[@]%.gpg}" ) -password=$(printf '%s\n' "${password_files[@]}" | "$dmenu" -fn "$font" "$@") +password=$(printf '%s\n' "${password_files[@]}" | "$dmenu" -fn "$font" -i "$@") [[ -n $password ]] || exit @@ -44,7 +44,7 @@ if [[ $typeit -eq 0 ]]; then pass -c "$password" 2>/dev/null url=$(echo "$selection" | sed -n 3p) if [[ "$url" ]]; then - openUrl=$(printf "yes\nno" | "$dmenu" -fn "$font" "$@" -p "Open $url in browser?") + openUrl=$(printf "yes\nno" | "$dmenu" -fn "$font" -i "$@" -p "Open $url in browser?") if [[ "$openUrl" == yes ]]; then xdg-open "$url" & disown fi diff --git a/bin/radio b/bin/radio @@ -11,7 +11,7 @@ file=~/Desktop/radiostations readarray -t stations < "$file" -stationName=$(printf '%s\n' "${stations[@]}" | cut -f1 -d ';' | "$dmenu" -fn "$font" -l "$lines" "$@") +stationName=$(printf '%s\n' "${stations[@]}" | cut -f1 -d ';' | "$dmenu" -fn "$font" -i -l "$lines" "$@") for i in "${stations[@]}"