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
}
updates_output() {
notify=$1
if ! [[ -z $updates_arch ]]; then
echo "ARCH: $(echo "$updates_arch" | wc -l )"
[[ -z $notify ]] && echo "$updates_arch"
fi
if ! [[ -z $updates_aur ]]; then
echo "AUR:"
[[ -z $notify ]] && echo "$updates_aur"
fi
notify=$1
if ! [[ -z $updates_arch ]]; then
echo "ARCH: $(echo "$updates_arch" | wc -l)"
[[ -z $notify ]] && echo "$updates_arch"
fi
if ! [[ -z $updates_aur ]]; then
echo "AUR: $(echo "$updates_aur" | wc -l)"
[[ -z $notify ]] && echo "$updates_aur"
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
case $opt in
@ -32,8 +36,8 @@ for opt in "$@"; do
usage
;;
--notify)
notify=1
shift
notify=1
shift
;;
-* | --*)
echo "Invalid option: $opt"
@ -43,17 +47,21 @@ for opt in "$@"; do
esac
done
updates_arch="$(checkupdates 2> /dev/null | awk '{print $1}')"
updates_aur="$(pikaur -Qua 2> /dev/null | awk '{print $1}')"
echo "fetching updates..."
updates_arch="$(checkupdates 2>/dev/null | awk '{print $1}')"
updates_aur="$(pikaur -Qua 2>/dev/null | awk '{print $1}')"
updates_info="$(updates_output $notify)"
if [[ -z $updates_info ]];then
exit 0
if [[ -z $updates_info ]]; then
echo "system up to date"
exit 0
fi
if ! [[ -z $notify ]]; then
notify-send -t 60000 "System Updates Available!" "$updates_info"
notify-send -w "System Updates Available!" "$updates_info"
else
echo "System Updates Available!"
echo "$updates_info"
echo "System Updates Available!"
echo "$updates_info"
update_system
fi

View file

@ -43,9 +43,9 @@ make_figlet() {
}
font_size=25
font_to_px=$(( $font_size * 16 / 12 ))
greeter_h=$(($(make_figlet | wc -l) * $font_to_px))
greeter_w=$(($(make_figlet | wc -L ) * $font_to_px))
font_to_px=$((font_size * 16 / 12))
greeter_h=$(($(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"
@ -57,34 +57,33 @@ sleep 0.1
# lock the screen
i3lock \
-n \
-n \
--screen 1 \
\
\
--color $bg_color \
--inside-color ffffff00 \
--inside-color ffffff00 \
--ring-color $green \
--ringwrong-color $red \
--ringver-color $cyan \
--insidewrong-color $bg_color \
--insidever-color $bg_color \
--line-uses-ring \
--separator-color $selection \
--line-uses-ring \
--separator-color $selection \
--keyhl-color $cyan \
--bshl-color $red \
--wrong-color $red \
\
--ind-pos x+w-5-r:y+h-10-r \
--ring-width 25 \
--radius 100 \
\
--ind-pos x+w-5-r:y+h-10-r \
--ring-width 25 \
--radius 100 \
--verif-text "" \
\
--greeter-text "$(make_figlet)" \
\
--greeter-text "$(make_figlet)" \
--greeter-font "${font}" \
--greeter-size $font_size \
--greeter-color $cyan \
--greeter-pos "${greeter_pos}" \
--greeter-align 1 \
--greeter-pos "${greeter_pos}" \
--greeter-align 1
# resume message display
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)
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" "")
user_cell=$(printf "%${user_len}s" "")
@ -116,7 +116,7 @@ list() {
"${CYAN}tool${NORMAL}%s | \
${CYAN}author${NORMAL}%s | \
${CYAN} install date${NORMAL}\n" \
"${tool_cell:4}" "${user_cell:6}"
"${tool_cell:4}" "${user_cell:6}"
printf "%${table_width}s\n" "" | tr ' ' -
readarray tools < <(yq e 'keys | .[]' $YAMLDOC)
#sort tools for readability
@ -125,11 +125,11 @@ ${CYAN} install date${NORMAL}\n" \
user=$(key=$tool yq e 'explode(.) | .[env(key)].user' $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)
! [[ -z "$modified" ]] && installed=$INSTALL_YES || installed=$INSTALL_NO
! [[ -z $modified ]] && installed=$INSTALL_YES || installed=$INSTALL_NO
printf \
"${MAGENTA}%s${NORMAL}%s | \