shell formatting
This commit is contained in:
parent
5faafce31c
commit
627d00c94a
3 changed files with 47 additions and 40 deletions
|
@ -12,7 +12,6 @@ HELP
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
updates_output() {
|
updates_output() {
|
||||||
notify=$1
|
notify=$1
|
||||||
if ! [[ -z $updates_arch ]]; then
|
if ! [[ -z $updates_arch ]]; then
|
||||||
|
@ -20,11 +19,16 @@ updates_output() {
|
||||||
[[ -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
|
||||||
|
|
||||||
|
echo "fetching updates..."
|
||||||
|
|
||||||
updates_arch="$(checkupdates 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_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
|
||||||
|
|
|
@ -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"
|
||||||
|
|
||||||
|
@ -83,8 +83,7 @@ i3lock \
|
||||||
--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" "")
|
||||||
|
|
||||||
|
@ -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