shell formatting
This commit is contained in:
parent
5faafce31c
commit
627d00c94a
3 changed files with 47 additions and 40 deletions
|
@ -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
|
||||||
|
@ -32,8 +36,8 @@ for opt in "$@"; do
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
--notify)
|
--notify)
|
||||||
notify=1
|
notify=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-* | --*)
|
-* | --*)
|
||||||
echo "Invalid option: $opt"
|
echo "Invalid option: $opt"
|
||||||
|
@ -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
|
||||||
exit 0
|
echo "system up to date"
|
||||||
|
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
|
||||||
|
|
|
@ -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"
|
||||||
|
|
||||||
|
@ -57,34 +57,33 @@ sleep 0.1
|
||||||
|
|
||||||
# lock the screen
|
# lock the screen
|
||||||
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 \
|
||||||
--ringwrong-color $red \
|
--ringwrong-color $red \
|
||||||
--ringver-color $cyan \
|
--ringver-color $cyan \
|
||||||
--insidewrong-color $bg_color \
|
--insidewrong-color $bg_color \
|
||||||
--insidever-color $bg_color \
|
--insidever-color $bg_color \
|
||||||
--line-uses-ring \
|
--line-uses-ring \
|
||||||
--separator-color $selection \
|
--separator-color $selection \
|
||||||
--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
|
||||||
|
|
||||||
|
|
|
@ -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" "")
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ list() {
|
||||||
"${CYAN}tool${NORMAL}%s | \
|
"${CYAN}tool${NORMAL}%s | \
|
||||||
${CYAN}author${NORMAL}%s | \
|
${CYAN}author${NORMAL}%s | \
|
||||||
${CYAN} install date${NORMAL}\n" \
|
${CYAN} install date${NORMAL}\n" \
|
||||||
"${tool_cell:4}" "${user_cell:6}"
|
"${tool_cell:4}" "${user_cell:6}"
|
||||||
printf "%${table_width}s\n" "" | tr ' ' -
|
printf "%${table_width}s\n" "" | tr ' ' -
|
||||||
readarray tools < <(yq e 'keys | .[]' $YAMLDOC)
|
readarray tools < <(yq e 'keys | .[]' $YAMLDOC)
|
||||||
#sort tools for readability
|
#sort tools for readability
|
||||||
|
@ -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 | \
|
||||||
|
|
Loading…
Reference in a new issue