shell formatting

This commit is contained in:
Daylin Morgan 2022-06-15 14:28:16 -05:00
parent 5faafce31c
commit 627d00c94a
3 changed files with 47 additions and 40 deletions

View file

@ -12,19 +12,23 @@ HELP
exit 0 exit 0
} }
updates_output() { updates_output() {
notify=$1 notify=$1
if ! [[ -z $updates_arch ]]; then if ! [[ -z $updates_arch ]]; then
echo "ARCH: $(echo "$updates_arch" | wc -l )" echo "ARCH: $(echo "$updates_arch" | wc -l)"
[[ -z $notify ]] && echo "$updates_arch" [[ -z $notify ]] && echo "$updates_arch"
fi fi
if ! [[ -z $updates_aur ]]; then if ! [[ -z $updates_aur ]]; then
echo "AUR:" echo "AUR: $(echo "$updates_aur" | wc -l)"
[[ -z $notify ]] && echo "$updates_aur" [[ -z $notify ]] && echo "$updates_aur"
fi fi
echo
} }
update_system() {
read -p "Would you like to update? (y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
pikaur -Syu
}
for opt in "$@"; do for opt in "$@"; do
case $opt in case $opt in
@ -43,17 +47,21 @@ for opt in "$@"; do
esac esac
done done
updates_arch="$(checkupdates 2> /dev/null | awk '{print $1}')" echo "fetching updates..."
updates_aur="$(pikaur -Qua 2> /dev/null | awk '{print $1}')"
updates_arch="$(checkupdates 2>/dev/null | awk '{print $1}')"
updates_aur="$(pikaur -Qua 2>/dev/null | awk '{print $1}')"
updates_info="$(updates_output $notify)" updates_info="$(updates_output $notify)"
if [[ -z $updates_info ]];then if [[ -z $updates_info ]]; then
echo "system up to date"
exit 0 exit 0
fi fi
if ! [[ -z $notify ]]; then if ! [[ -z $notify ]]; then
notify-send -t 60000 "System Updates Available!" "$updates_info" notify-send -w "System Updates Available!" "$updates_info"
else else
echo "System Updates Available!" echo "System Updates Available!"
echo "$updates_info" echo "$updates_info"
update_system
fi fi

View file

@ -43,9 +43,9 @@ make_figlet() {
} }
font_size=25 font_size=25
font_to_px=$(( $font_size * 16 / 12 )) font_to_px=$((font_size * 16 / 12))
greeter_h=$(($(make_figlet | wc -l) * $font_to_px)) greeter_h=$(($(make_figlet | wc -l) * font_to_px))
greeter_w=$(($(make_figlet | wc -L ) * $font_to_px)) greeter_w=$(($(make_figlet | wc -L) * font_to_px))
greeter_pos="x+w/2-${greeter_w}/4:y+h/2-${greeter_h}/4" greeter_pos="x+w/2-${greeter_w}/4:y+h/2-${greeter_h}/4"
@ -59,7 +59,7 @@ sleep 0.1
i3lock \ i3lock \
-n \ -n \
--screen 1 \ --screen 1 \
\ \
--color $bg_color \ --color $bg_color \
--inside-color ffffff00 \ --inside-color ffffff00 \
--ring-color $green \ --ring-color $green \
@ -72,19 +72,18 @@ i3lock \
--keyhl-color $cyan \ --keyhl-color $cyan \
--bshl-color $red \ --bshl-color $red \
--wrong-color $red \ --wrong-color $red \
\ \
--ind-pos x+w-5-r:y+h-10-r \ --ind-pos x+w-5-r:y+h-10-r \
--ring-width 25 \ --ring-width 25 \
--radius 100 \ --radius 100 \
--verif-text "" \ --verif-text "" \
\ \
--greeter-text "$(make_figlet)" \ --greeter-text "$(make_figlet)" \
--greeter-font "${font}" \ --greeter-font "${font}" \
--greeter-size $font_size \ --greeter-size $font_size \
--greeter-color $cyan \ --greeter-color $cyan \
--greeter-pos "${greeter_pos}" \ --greeter-pos "${greeter_pos}" \
--greeter-align 1 \ --greeter-align 1
# resume message display # resume message display
pkill -u "$USER" -USR2 dunst pkill -u "$USER" -USR2 dunst

View file

@ -106,7 +106,7 @@ list() {
user_len=$(yq e '.[] | .user ' $YAMLDOC | tail -n +2 | sort | uniq | awk '{print length}' | sort -nr | head -n 1) user_len=$(yq e '.[] | .user ' $YAMLDOC | tail -n +2 | sort | uniq | awk '{print length}' | sort -nr | head -n 1)
tool_len=$(yq e 'keys| .[]' $YAMLDOC | tail -n +2 | sort | uniq | awk '{print length}' | sort -nr | head -n 1) tool_len=$(yq e 'keys| .[]' $YAMLDOC | tail -n +2 | sort | uniq | awk '{print length}' | sort -nr | head -n 1)
table_width=$(($user_len + $tool_len + 25)) table_width=$((user_len + tool_len + 25))
tool_cell=$(printf "%${tool_len}s" "") tool_cell=$(printf "%${tool_len}s" "")
user_cell=$(printf "%${user_len}s" "") user_cell=$(printf "%${user_len}s" "")
@ -125,11 +125,11 @@ ${CYAN} install date${NORMAL}\n" \
user=$(key=$tool yq e 'explode(.) | .[env(key)].user' $YAMLDOC) user=$(key=$tool yq e 'explode(.) | .[env(key)].user' $YAMLDOC)
bin_name=$(key=$tool yq e 'explode(.) | .[env(key)].to' $YAMLDOC) bin_name=$(key=$tool yq e 'explode(.) | .[env(key)].to' $YAMLDOC)
[[ "$bin_name" == "null" ]] && bin_name=$tool [[ $bin_name == "null" ]] && bin_name=$tool
modified=$(check_install $bin_name) modified=$(check_install $bin_name)
! [[ -z "$modified" ]] && installed=$INSTALL_YES || installed=$INSTALL_NO ! [[ -z $modified ]] && installed=$INSTALL_YES || installed=$INSTALL_NO
printf \ printf \
"${MAGENTA}%s${NORMAL}%s | \ "${MAGENTA}%s${NORMAL}%s | \