Compare commits

...

3 Commits

Author SHA1 Message Date
Tuxliban Torvalds d0c83ca9a1 vtewheel: nuevo
Script para terminal urxvt-unicode. Sirve para añadir la función de desplazamiento con el mouse cuando se usa vim, less, man, etc
2022-01-13 13:43:56 -06:00
Tuxliban Torvalds 36ca6c200b xpkglocal: corrección de código
Se arregló opción de escalado de privilegios y filtro de obtención de actualizaciones en upstream
2022-01-13 13:36:10 -06:00
Tuxliban Torvalds adff25920d updates_void: corrección y simplificación de código 2022-01-13 13:23:22 -06:00
3 changed files with 105 additions and 34 deletions

55
varios/perl/vtewheel Normal file
View File

@ -0,0 +1,55 @@
#!/usr/bin/env perl -w
# Implementa el desplazamiento del ratón cuando se utiliza vim, less, man, etc
# 1. Colocar este script en alguno de los siguientes directorios:
# /usr/lib/urxvt/perl/
# "$HOME"/.urxvt/ext/perl/
# 2. Después, agregar:
# URxvt.perl-ext-common:vtewheel
# En el fichero .Xdefaults o .Xresources
# 3. Finalmente ejecutar (según sea el caso) para cargar la nueva configuración:
# xrdb -merge "$HOME/.Xdefaults"
# xrdb -merge "$HOME/.Xresources"
sub simulate_keypress {
my ($self, $type) = @_; #type: 0:up, 1:down
my $keycode_up = 111;
my $keycode_down = 116;
my $numlines = 3;
my $keycode = 0;
if ($type eq 0) {
$keycode = $keycode_up;
} elsif ($type eq 1) {
$keycode = $keycode_down;
} else {
return;
}
for (my $i = 0 ; $i ne $numlines ; $i++) {
$self->key_press(0,$keycode);
$self->key_release(0,$keycode);
}
}
sub on_button_release {
my ($self, $event) = @_;
#my $res_ss = $self->resource("secondaryScroll");
#warn("ressource ss is <$res_ss>");
!$self->current_screen and return ();
#warn("foo, event: <$event->{button}>\n");
if ($event->{button} eq "4") { # scroll up
$self->simulate_keypress(0);
return 1;
} elsif ($event->{button} eq "5") { # scroll down
$self->simulate_keypress(1);
return 1;
}
return ();
}

View File

@ -1,24 +1,25 @@
#!/bin/sh
/usr/bin/xbps-install.static -nuM 1>/tmp/updates 2>/tmp/error
TMP_UPDATES=/tmp/updates_void
[ -d "${TMP_UPDATES}" ] || mkdir "${TMP_UPDATES}"
updates="$(wc -l < /tmp/updates)"
broken="$(grep -c broken /tmp/error)"
pkg="$(awk '{print $1" ---> "$2}' /tmp/updates)"
pkgs="$(awk '{print $1}' /tmp/updates)"
xx=$(printf "==============================")
#/usr/bin/xbps-install.static -nuM 1>/tmp/updates 2>/tmp/error
xbps-install -nuM 1>"${TMP_UPDATES}"/updates 2>"${TMP_UPDATES}"/error
updates="$(wc -l < "${TMP_UPDATES}"/updates)"
broken="$(grep -c broken "${TMP_UPDATES}"/error)"
pkgs="$(awk '{print $1" ---> " $2}' "${TMP_UPDATES}"/updates)"
xx=$(printf "========================================")
if [ "$broken" = 0 ] && [ "$updates" -ge 1 ]; then
"$HOME"/Dropbox/Gitea/scripts/varios/dunst_sound
if [ "$updates" -eq 1 ]; then
herbe "ACTUALIZACIÓN DISPONIBLE:" "$xx $pkg"
elif [ "$updates" -gt 1 ]; then
herbe "ACTUALIZACIONES DISPONIBLES: $updates" "$xx $pkgs"
else
echo ""
fi
herbe "ACTUALIZACIONES DISPONIBLES: $updates" "$xx" "$pkgs"
else
echo ""
fi
if [ "$broken" -ge 1 ]; then
herbe "HAY PAQUETES ROTOS:" "$xx" "$(cut -d " " -f 1,5 /tmp/error)"
herbe "HAY PAQUETES ROTOS:" "$xx" "$(cut -d " " -f 1,5 "${TMP_UPDATES}"/error)"
fi
exit 0

View File

@ -4,40 +4,55 @@
# Se recomienda añadir este script en una tarea de crontab
# Dependencias: xbps-src, xtools
TMP_DIR=/tmp/xpkglocal
mkdir "${TMP_DIR}"
which_sudo() {
if command -v sudo >/dev/null && sudo -l | grep -q -e ' ALL$' -e xbps-install; then
echo sudo
elif command -v doas >/dev/null && [ -f /etc/doas.conf ]; then
echo doas
elif [ "$(id -u)" != 0 ]; then
echo su
fi
}
do_install() {
if [ "$SUDO" = su ]; then
su root -c 'xbps-install "$@"' -- sh "$@"
else
$SUDO xbps-install "$@"
fi
}
# Verificar que las dependencias estén instaladas
if [ ! -f /usr/bin/xpkg ]; then
printf "Instalando paquete xtools"
doas xbps-install -Sy xtools
#else
# sudo xbps-install -Sy xtools
if [ ! -f /usr/bin/xpkg ] && printf "Instalando paquete xtools"; then
SUDO=$(which_sudo)
do_install -Sy "$@"
fi
if [ ! -f "$HOME/void-packages/xbps-src" ]; then
printf "No se encontró repositorio git de Void Linux. Clonadolo..."
git -C "$HOME" clone --depth=1 https://github.com/void-linux/void-packages.git
cd void-packages || exit
cd "$HOME"/void-packages || exit
./xbps-src binary-bootstrap
echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf
fi
# Crear un fichero temporal que se usará para listar actualizaciones disponibles
# a través de una notificación emergente
if [ -f /tmp/upstream_releases ]; then
rm /tmp/upstream_releases
touch /tmp/upstream_releases
else
touch /tmp/upstream_releases
fi
cd "$HOME"/void-packages || exit
touch "${TMP_DIR}"/upstream_releases
#for i in $(xbps-query -m | xargs -n1 xbps-uhelper getpkgname); do
for i in $(xpkg -L); do
./xbps-src update-check "$i" | tee -a /tmp/upstream_releases
./xbps-src update-check "$i" | tail -n 1 | tee -a "${TMP_DIR}"/upstream_releases > /dev/null
done
updates=$(uniq /tmp/upstream_releases | wc -l)
upstream=$(uniq /tmp/upstream_releases)
xx=$(printf "==============================")
updates="$(wc -l < "${TMP_DIR}"/upstream_releases)"
releases="$(cat "${TMP_DIR}"/upstream_releases)"
xx="$(printf ========================================)"
if [ "$updates" -gt 0 ]; then
herbe "ACTUALIZACIONES EN UPSTREAM:" "$xx $upstream"
herbe "ACTUALIZACIONES EN UPSTREAM: $xx $releases"
fi
rm -r "$TMP_DIR"
exit 0