updates-void.sh: update to 1.0

Se cambia el nombre de la variables de mayúsculas a minúsculas y se modifica el tipo de font y tamaño de fuente para la notificación
This commit is contained in:
Tuxliban Torvalds 2023-09-21 21:00:18 -06:00
parent ca680592b1
commit 0cd108b1d5
1 changed files with 17 additions and 15 deletions

32
varios/updates-void.sh Executable file → Normal file
View File

@ -1,4 +1,6 @@
#!/bin/sh
#
# v1.0 - 20/09/2023
# Script que revisa si existen actualizaciones disponibles para el sistema
# Dependencas: dzen2
#
@ -9,16 +11,16 @@
# 4 - Operación exitosa, pero no hubo cambios
#
# Shell: POSIX compliant
# Autor: O. Sánchez <o-sanchez@linuxmail.org>
# Autor: O. Sánchez <o-sanchez@linuxmail.org> 2020 - 2023
set -u
TMP_UPDATES=$(mktemp -d /tmp/updates_void.XXXX)
xbps-install -nuM 1>"${TMP_UPDATES}"/updates 2>"${TMP_UPDATES}"/error
tmp_updates=$(mktemp -d /tmp/updates_void.XXXX)
xbps-install -nuM 1>"${tmp_updates}"/updates 2>"${tmp_updates}"/error
UPDATES="$(awk 'END {print NR}' "${TMP_UPDATES}"/updates)"
BROKEN="$(grep -c broken "${TMP_UPDATES}"/error)"
PKGS="$(awk '{printf "%-30s %s\n", $1, $2}' "${TMP_UPDATES}"/updates)"
updates="$(awk 'END {print NR}' "${tmp_updates}"/updates)"
broken="$(grep -c broken "${tmp_updates}"/error)"
pkgs="$(awk '{printf "%-30s %s\n", $1, $2}' "${tmp_updates}"/updates)"
deps() {
if ! command -v dzen2 >/dev/null; then
@ -28,23 +30,23 @@ deps() {
}
msg() {
dzen2 -p -fn 'JetBrains Mono:size=8:style=bold' -ta 5 \
dzen2 -p -fn 'Inconsolata:size=10:style=bold' -ta 5 \
-w 260 -x 1100 -y 25 -l 10
}
if deps; then
if [ "$BROKEN" = 0 ] && [ "$UPDATES" -ge 1 ]; then
"$HOME"/Dropbox/Gitea/scripts/varios/dunst_sound
printf '%s\n' "ACTUALIZACIONES DISPONIBLES: $UPDATES" "$PKGS" | msg &
rm -r "${TMP_UPDATES}"
if [ "$broken" = 0 ] && [ "$updates" -ge 1 ]; then
"$HOME"/.local/bin/alert
printf '%s\n' "ACTUALIZACIONES DISPONIBLES: $updates" "$pkgs" | msg &
rm -r "${tmp_updates}"
exit 0
elif [ "$BROKEN" -ge 1 ]; then
elif [ "$broken" -ge 1 ]; then
printf '%s\n' "HAY PAQUETES ROTOS" "$(awk '{printf "%-30s %s\n", $1, $5}' \
"${TMP_UPDATES}"/error)" | msg &
rm -r "${TMP_UPDATES}"
"${tmp_updates}"/error)" | msg &
rm -r "${tmp_updates}"
exit 3
else
[ -z "$UPDATES" ] || rm -r "${TMP_UPDATES}"
[ -z "$updates" ] || rm -r "${tmp_updates}"
exit 4
fi
fi