scripts

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

commit 8e19e9e71fe4fc3f6c5f4a4ba1cd7b42edfa22d1
parent 7cb7c555f9dd5b8a6a2813fc16997a4f24ba8a85
Author: Wim Dupont <wim@wimdupont.com>
Date:   Thu,  1 Feb 2024 14:48:00 +0100

removed redundant variables

Diffstat:
Mbin/bookmark | 7++-----
Mbin/mpvd | 12++++--------
Mbin/otp | 4++--
Mbin/pclip | 4+---
Mbin/pwu | 7+++----
Mbin/radio | 5+----
6 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/bin/bookmark b/bin/bookmark @@ -4,22 +4,19 @@ source ~/.config/scripts/properties shopt -s nullglob globstar -readonly FONT=$DMENU_FONT -readonly LINES=$DMENU_LINES -readonly DMENU=dmenu readonly BOOKMARK_FILE=~/.config/scripts/bookmarks readonly SEARCH_URI="http://localhost/search?q=" readarray -t bookmarks < "$BOOKMARK_FILE" -bookmark=$(printf '%s\n' "${bookmarks[@]}" | "$DMENU" -fn "$FONT" -i -l "$LINES" "$@") +bookmark=$(printf '%s\n' "${bookmarks[@]}" | "$dmenu" -fn "$dmenu_font" -i -l "$dmenu_lines" "$@") if [ -z "${bookmark}" ]; then exit 0 fi if [[ ! ${bookmark} =~ ^(https?://*) ]]; then - readonly WITH_SEARCH_ENGINE=$(printf "yes\nno" | "$DMENU" -fn "$FONT" -i "$@" -p "Use search engine?") + readonly WITH_SEARCH_ENGINE=$(printf "yes\nno" | "$dmenu" -fn "$dmenu_font" -i "$@" -p "Use search engine?") if [[ "${WITH_SEARCH_ENGINE}" == yes ]]; then bookmark="${SEARCH_URI}${bookmark}" else diff --git a/bin/mpvd b/bin/mpvd @@ -4,10 +4,6 @@ source ~/.config/scripts/properties shopt -s nullglob globstar -readonly FONT=$DMENU_FONT -readonly LINES=$DMENU_LINES -readonly DMENU=dmenu - prefix=${MUSIC_DIR-~/Music} musicdirs=( "$prefix"/*/) @@ -22,11 +18,11 @@ done songdirs=( "${songdirs[@]#"$prefix"/}" ) songdirs=( "${songdirs[@]%/}" ) -songdir=$(printf '%s\n' "${songdirs[@]}" | "$DMENU" -fn "$FONT" -i -l "$LINES" "$@") +songdir=$(printf '%s\n' "${songdirs[@]}" | "$dmenu" -fn "$dmenu_font" -i -l "$dmenu_lines" "$@") [[ -n $songdir ]] || exit -playsongdir=$(printf "no\nyes" | "$DMENU" -fn "$FONT" -i "$@" -p "Play full directory?") +playsongdir=$(printf "no\nyes" | "$dmenu" -fn "$dmenu_font" -i "$@" -p "Play full directory?") [[ -n $playsongdir ]] || exit @@ -35,10 +31,10 @@ if [[ "$playsongdir" == no ]]; then songdirs=( "$prefix"/**/*) songdirs=( "${songdirs[@]#"$prefix"/}" ) songdirs=( "${songdirs[@]%}" ) - songdir=$(printf '%s\n' "${songdirs[@]}" | "$DMENU" -fn "$FONT" -i -l "$LINES" "$@") + songdir=$(printf '%s\n' "${songdirs[@]}" | "$dmenu" -fn "$dmenu_font" -i -l "$dmenu_lines" "$@") [[ -n $songdir ]] || exit else - random=$(printf "no\nyes" | "$DMENU" -fn "$FONT" -i "$@" -p "Shuffle?") + random=$(printf "no\nyes" | "$dmenu" -fn "$dmenu_font" -i "$@" -p "Shuffle?") [[ -n $random ]] || exit diff --git a/bin/otp b/bin/otp @@ -3,7 +3,7 @@ source ~/.config/scripts/properties shopt -s nullglob globstar -readonly FONT=$DMENU_FONT + typeit=0 while getopts ":t" arg; do @@ -64,7 +64,7 @@ if [ -n "${value}" ]; then fi fi else - password=$(printf '%s\n' "${password_files[@]}" | "$dmenu" -fn "$FONT" -i ) + password=$(printf '%s\n' "${password_files[@]}" | "$dmenu" -fn "$dmenu_font" -i ) [[ -n $password ]] || exit use_arg_file "${password}" diff --git a/bin/pclip b/bin/pclip @@ -4,8 +4,6 @@ source ~/.config/scripts/properties shopt -s nullglob globstar -readonly FONT=$DMENU_FONT - shift $((OPTIND-1)) if [[ -n $WAYLAND_DISPLAY ]]; then @@ -28,7 +26,7 @@ clipboards[0]=$(echo -n "Primary: ${primary}" | tr -d '\n') clipboards[1]=$(echo -n "Secondary: ${secondary}" | tr -d '\n') clipboards[2]=$(echo -n "Clipboard: ${clipboard}" | tr -d '\n') -selected=$(printf '%s\n' "${clipboards[@]}" | "$dmenu" -fn "$FONT" -i -l 10 "$@" ) +selected=$(printf '%s\n' "${clipboards[@]}" | "$dmenu" -fn "$dmenu_font" -i -l 10 "$@" ) [[ -n "${selected}" ]] || exit diff --git a/bin/pwu b/bin/pwu @@ -4,7 +4,6 @@ source ~/.config/scripts/properties shopt -s nullglob globstar -readonly FONT=$DMENU_FONT typeit=0 no_console=0 @@ -63,7 +62,7 @@ function use_file () { if [[ "$url" ]]; then if [[ $quiet == 0 ]]; then if [[ $typeit -eq 0 ]]; then - openUrl=$(printf "yes\nno" | "$dmenu" -fn "$FONT" -i -p "Open $url in browser?") + openUrl=$(printf "yes\nno" | "$dmenu" -fn "$dmenu_font" -i -p "Open $url in browser?") if [[ "$openUrl" == yes ]]; then xdg-open "${url}" >/dev/null 2>&1 & disown fi @@ -110,7 +109,7 @@ function use_otp () { [[ $no_console == 0 ]] || exit if [[ $quiet == 0 ]]; then read -p "Press enter to continue" - copyOtp=$(printf "yes\nno" | "$dmenu" -fn "$FONT" -i -p "Copy OTP to clipboard?") + copyOtp=$(printf "yes\nno" | "$dmenu" -fn "$dmenu_font" -i -p "Copy OTP to clipboard?") if [[ "$copyOtp" == yes ]]; then clip_or_type_otp "$file" fi @@ -169,7 +168,7 @@ if [ -n "${value}" ]; then fi fi else - value=$(printf '%s\n' "${password_files[@]}" | "$dmenu" -fn "$FONT" -i ) + value=$(printf '%s\n' "${password_files[@]}" | "$dmenu" -fn "$dmenu_font" -i ) [[ -n $value ]] || exit use_file "${value}" diff --git a/bin/radio b/bin/radio @@ -4,14 +4,11 @@ source ~/.config/scripts/properties shopt -s nullglob globstar -readonly FONT=$DMENU_FONT -readonly LINES=$DMENU_LINES -readonly DMENU=dmenu readonly FILE=~/.config/scripts/radiostations readarray -t stations < "${FILE}" -station_name=$(printf '%s\n' "${stations[@]}" | cut -f1 -d ';' | "$DMENU" -fn "$FONT" -i -l "$LINES" "$@") +station_name=$(printf '%s\n' "${stations[@]}" | cut -f1 -d ';' | "$dmenu" -fn "$dmenu_font" -i -l "$dmenu_lines" "$@") for i in "${stations[@]}"