Compare commits

...

4 Commits

Author SHA1 Message Date
Tuxliban Torvalds 1962204fd7 Se añaden scripts de Korn Shell 2023-05-05 18:57:30 -06:00
Tuxliban Torvalds 379798d954 Renombrado de scripts
Se ha añadido la extensión .sh para poder identificar que se tratan de script de shell
2023-05-05 18:50:15 -06:00
Tuxliban Torvalds 93d6e98e6c functions: funciones para ksh93 2023-05-05 18:24:23 -06:00
Tuxliban Torvalds 809157337b i3blocks: Reubicación de script 2023-05-05 17:03:47 -06:00
140 changed files with 3281 additions and 912 deletions

View File

@ -0,0 +1,9 @@
# Añadir esta configuración en /root/.profile para personalizar el prompt para root
function admin_prompt
{
[[ $PWD == $HOME ]] && dir="~" || dir="${PWD#*/}"
print "${YELLOW}[$dir] ${GREEN}#${RED} "
}
PS1="\$(admin_prompt) "

11
functions_korn/count Normal file
View File

@ -0,0 +1,11 @@
# Contar archivos o directorios en el directorio
# Esto funciona pasando la salida del glob a la función y luego contando el número de argumentos.
function count
{
# Uso:
# count /path/to/dir/* -> Total (archivos y directorios)
# count /path/to/dir/*/ -> Total de directorios
[[ -e $1 ]] && print "$#" || print 0
}

View File

@ -0,0 +1,13 @@
# Obtener el número de líneas de un fichero
function count_lines
{
lines=0
while IFS= read -r line || [[ -n $line ]]; do
# lines=$((lines+1)) is slower than ((lines=lines+1))
((lines=lines+1))
done < "$1"
printf '%s\n' "$lines"
}

29
functions_korn/extraer Normal file
View File

@ -0,0 +1,29 @@
# Extrar archivos comprimidos y/o empaquetados
function ex
{
if [ -f "$1" ]; then
case $1 in
*.tar.bz2)
bsdtar -xvjf "$1"
;;
*.tar.gz)
bsdtar -xvzf "$1"
;;
*.rar)
bsdtar -xf "$1"
;;
*.tar.xz)
bsdtar -xvjf "$1"
;;
*.zip)
bsdtar -xf "$1"
;;
*.7z)
bsdtar -xf "$1"
;;
*)
print "El archivo $1 no puede ser extraído. Formato desconocido"
esac || return 1
fi
}

11
functions_korn/get_branch Normal file
View File

@ -0,0 +1,11 @@
# Mostrar rama actual en directorios de git
function get_branch
{
BRANCH=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
if [[ ! -z ${BRANCH} ]]; then
print "${BRANCH}"
fi
unset BRANCH
}

6
functions_korn/get_dir Normal file
View File

@ -0,0 +1,6 @@
# Mostrar directorio de trabajo actual
function get_dir
{
printf '%s\n' ${PWD/$HOME/\~}
}

12
functions_korn/ll Normal file
View File

@ -0,0 +1,12 @@
# Función personalizada para ls
# Dependiendo del número de entradas, mostrará el contenido ajustándolo a la pantalla
function ll
{
local __lstmp=$(command ls -X -1 --color=always "$@")
if [ ! $( print "$__lstmp" | wc -l) -gt $LINES ]; then
print "$__lstmp"
else
command ls -C --color=always "$@"
fi
}

13
functions_korn/man Normal file
View File

@ -0,0 +1,13 @@
# Mostrar los manuales de los programa con color
function man
{
LESS_TERMCAP_mb=$(printf %b "\033[1;31m") \
LESS_TERMCAP_md=$(printf %b "\033[1;31m") \
LESS_TERMCAP_me=$(printf %b "\033[0m") \
LESS_TERMCAP_se=$(printf %b "\033[0m") \
LESS_TERMCAP_so=$(printf %b "\033[1;44;33m") \
LESS_TERMCAP_ue=$(printf %b "\033[0m") \
LESS_TERMCAP_us=$(printf %b "\033[1;32m") \
command man -a "$@"
}

7
functions_korn/mkcd Normal file
View File

@ -0,0 +1,7 @@
# Crear un directorio y cambiar a él
function mkcd
{
mkdir -p -- "$1" || return
cd -P -- "$1"
}

9
functions_korn/prompt Normal file
View File

@ -0,0 +1,9 @@
# Prompt para usuario normal
function prompt
{
print "${GREEN}${PWD/$HOME/\~} ${CYAN}$(get_branch)"
print "${RED}-> ${YELLOW}$ ${NORM}"
}
PS1="\$(prompt) "

11
functions_korn/rman Normal file
View File

@ -0,0 +1,11 @@
# Consultar manuales de programa remotos
rman() {
if command -v lynx >/dev/null; then
lynx https://man.voidlinux.org/x86_64/"$@"
return 0
else
print "Instale el programa lynx"
return 1
fi
}

5
functions_korn/ver Normal file
View File

@ -0,0 +1,5 @@
# Consultar qué versión de shell korn se tiene en el sistema
ver() {
printf '%s\n' "Korn Shell: ${KSH_VERSION:-desconocida}"
}

13
functions_korn/which_sudo Normal file
View File

@ -0,0 +1,13 @@
# Función que se encarga de determinar qué programa usar para escalar
# permisos de administrador
function which_sudo
{
if command -v sudo >/dev/null && sudo -l | grep -q -e ' ALL$' -e xbps-install; then
print sudo
elif command -v doas >/dev/null && [ -f /etc/doas.conf ]; then
print doas
elif [[ $(id -u) != 0 ]]; then
print su
fi
}

View File

@ -1,34 +0,0 @@
#!/bin/bash
Bat=$(acpi | cut -d " " -f4 | tr -d "%,")
Adapt=$(acpi -a | cut -d " " -f3)
if [ "$Adapt" = "on-line" ];then
icon0=""
icon1=""
icon2=""
icon3=""
icon4=""
else
icon0=""
icon1=""
icon2=""
icon3=""
icon4=""
fi
if [ -z "$Bat" ];then
bat="$icon4 $Adapt"
elif [ "$Bat" -gt "100" ];then
bat="$icon4 Full"
elif [ "$Bat" -gt "90" ];then
bat="$icon3 $Bat %"
elif [ "$Bat" -gt "60" ];then
bat="$icon2 $Bat %"
elif [ "$Bat" -gt "30" ];then
bat="$icon1 $Bat %"
elif [ "$Bat" -lt "30" ];then
bat="$icon0 $Bat %"
fi
echo -e "$bat"

View File

@ -1,5 +0,0 @@
#!/bin/bash
Cpu=$(mpstat -u | grep "all" | awk '{print $4"%"}')
echo -e "$Cpu"

View File

@ -1,3 +0,0 @@
#!/bin/bash
echo -e "$(date +%D)$(date +%T)"

View File

@ -1,10 +0,0 @@
#!/bin/bash
Disk=$(df -h "$1" | grep -v "^[A-Z]" | awk '{print $3-G"/"$2}')
if [ -z "$1" ];then
echo -e "Enter Your Mounted Point Name Ex : \"/\" "
else
echo -e "$Disk "
fi
unset Disk

View File

@ -1,15 +0,0 @@
#!/bin/bash
focus=$(xdotool getactivewindow getwindowname)
focus_Number=$(xdotool getactivewindow getwindowname | wc -c)
Focus_N=$(xdotool getactivewindow getwindowname | head -c 40 )
if [ "$focus" = "" ];then
echo -e " : Void Linux "
else
if [ "$focus_Number" -gt "40" ];then
echo -e " : $Focus_N ..."
else
echo -e " : $focus"
fi
fi

View File

@ -1,5 +0,0 @@
#!/bin/bash
Key=$(setxkbmap -query | grep "^layout" | awk '{print $2}')
echo -e "$Key"

View File

@ -1,3 +0,0 @@
#!/bin/bash
echo -e "$LANGUAGE"

View File

@ -1,20 +0,0 @@
#!/bin/bash
Mem=$(free -h | grep "^Mem:" | awk '{print $3}')
Swap=$(free -h | grep "^Swap:" | awk '{print $3}')
if [ -z "$1" ];then
echo -e " $0 : no Argument \n\t -m : Show Memory usage \n\t -s : Show Swap usage "
fi
case "$1" in
"-m" )
echo -e "$Mem"
;;
"-s" )
echo -e "$Swap"
;;
esac
unset Mem
unset Swap

View File

@ -1,16 +0,0 @@
#!/bin/bash
Title=$(mocp -i | grep "^Title:" | cut -d ":" -f2)
NUM_Title=$(echo -e "$Title" | wc -c )
S_Title=$(echo -e "$Title" | head -c 30)
Status=$(mocp -i | grep "^State:" | cut -d ":" -f2)
if [ "$Status" != " PLAY" ];then
echo -e " : Pause"
else
if [ "$NUM_Title" -lt 30 ];then
echo -e " : $Title "
else
echo -e " : $S_Title ... "
fi
fi

View File

@ -1,14 +0,0 @@
#!/bin/bash
NCMP=$(mpc | grep "^\[playing\]" | awk '{print $1}')
NUM_NCMP=$(mpc | head -1 | wc -c )
S_NCMP=$(mpc | head -1 | head -c 30)
if [ "$NCMP" = "[playing]" ];then
if [ "$NUM_NCMP" -lt 30 ];then
echo -e " :$(mpc current) "
else
echo -e " : $S_NCMP..."
fi
else
echo -e " :Pause "
fi

View File

@ -1,39 +0,0 @@
#!/bin/bash
# Show Wifi Stuff
W_inter=$(ip link | grep "[1-9]: wlp" | cut -d " " -f2 | tr -d ':')
W_con=$(nmcli d | grep "$W_inter" | awk '{print $3}')
W_name=$(nmcli d | grep "$W_inter" | awk '{print $4}')
W_ip=$(ifconfig $W_inter | grep 'netmask' | awk '{print $6}')
# Show Ethernet stuff
E_inter=$(ip link | grep "^[1-9]: enp" | cut -d " " -f2 | tr -d :)
E_con=$(nmcli d | grep "$E_inter" | awk '{print $3}')
E_name=$(nmcli d | grep "$E_inter" | awk '{print $4}')
E_ip=$(ifconfig $E_inter | grep 'netmask' | awk '{print $6}')
Wifi () {
if [ "$W_con" = "connected" ];then
echo -w "$W_ip ($W_name)"
fi
}
Ethernet () {
if [ "$E_con" = "connected" ];then
echo -e "$E_ip ($E_name)"
fi
}
case "$1" in
"-w" )
Wifi
;;
"-e" )
Ethernet
;;
* )
echo -e " $0 : no Argument \n\t -e : Show Ethernet \n\t -w : Show Wireless"
;;
esac

View File

@ -1,5 +0,0 @@
#!/bin/bash
temp=$(sensors | grep "^CPU" | awk '{print $2}' | tr -d "+" )
echo -e "$temp"

View File

@ -1,9 +0,0 @@
#!/bin/bash
Status=$(synclient -l | grep Touchpad | awk '{print $3}')
if [ "$Status" = "0" ];then
echo -e "  Enable "
else
echo -e "  Disable "
fi

View File

@ -1,9 +0,0 @@
#!/bin/bash
trash=$(ls -A -1 ~/.local/share/Trash/files/ | wc -l)
if [ "$trash" = "0" ];then
echo -e ""
else
echo -e "$trash "
fi

View File

@ -1,9 +0,0 @@
#!/bin/bash
update=$(checkupdates | cut -d " " -f1 | wc -l)
if [ "$update" = "0" ];then
echo -e ""
else
echo -e "$Update"
fi

View File

@ -1,5 +0,0 @@
#!/bin/bash
UPTIME=$(uptime -p | sed "s/hour/H/" | sed "s/minutes/M/" | sed "s/up //")
echo -e "$UPTIME "

View File

@ -1,23 +0,0 @@
#!/bin/bash
Vol=$(amixer -c 0 get Master | grep "Mono:" | awk '{print $4}' | tr -d "[ %]")
Mute=$(amixer -c 0 get Master | grep "Mono:" | awk '{print $6}' | tr -d "[-]")
if [ "$Mute" = "off" ];then
echo -e " Mute"
else
if [ "$Vol" -gt "80" ];then
echo -e "$Vol %"
elif [ "$Vol" -gt "60" ];then
echo -e "$Vol %"
elif [ "$Vol" -gt "40" ];then
echo -e "$Vol %"
elif [ "$Vol" -gt "20" ];then
echo -e "$Vol %"
elif [ "$Vol" -eq "0" ];then
echo -e "$Vol %"
fi
fi
unset Vol
unset Mute

View File

@ -1,168 +0,0 @@
## Scripts sencillos pero funionales para utilizar con i3blocks. Siéntete libre de editarlos para adaptarlos a tus necesidades
| i3blocks Script | Dependencias |
|-----------------|-------------------|
| bat.sh | ACPI |
| date.sh | ------ |
| focus.sh | Xdotool |
| mem.sh | ------ |
| mpd.sh | Mpd, Ncmpcpp, Mpc |
| mocp.sh | Moc |
| temp.sh | lm-sensors |
| trash.sh | ---- |
| vol.sh | alsa-utils |
| cpu.sh | sysstat |
| disk.sh | ------ |
| key_l.sh | ------ |
| net.sh | ------ |
| touchpad.sh | ------ |
| update.sh | checkupdates |
| long.sh | ------ |
| uptime.sh | ------ |
---
### Instalación
git clone https://github...
### Configuración
##### Batería
[Bat]
command=~/.config/i3blocks/Blocks/bat.sh
interval=30
color=#CC0099
##### Fecha y hora
[Time]
command=~/.config/i3blocks/Blocks/date.sh
interval=60
color=#6699FF
##### Ventana enfocada
[Focus]
command=~/.config/i3blocks/Blocks/focus.sh
interval=1
color=#FF6666
##### Memoria ram
[Ram]
command=~/.config/i3blocks/Blocks/mem.sh -m
interval=10
color=#FF6600
##### Área de intercambio
[Swap]
command=~/.config/i3blocks/Blocks/mem.sh -s
interval=10
color=#6699FF
##### MPD
[MPD]
command=~/.config/i3blocks/Blocks/mpd.sh
interval=5
color=#66CCFF
##### Temperatura del cpu
[Temp]
command=~/.config/i3blocks/Blocks/temp.sh
interval=60
color=#6699FF
##### Papelera de reciclaje
[Trash]
command=~/.config/i3blocks/Blocks/trash.sh
interval=60
color=#c68c53
##### Volumen
[Vol]
command=~/.config/i3blocks/Blocks/Vol.sh
interval=3
color=#9933FF
##### Uso del cpu
[Cpu]
command=~/.config/i3blocks/Blocks/cpu.sh
interval=5
color=#FFFF66
##### Uso del disco
[Disk]
command=~/.config/i3blocks/Blocks/disk.sh /
interval=60
color=#CC6699
##### Distribución del teclado
[Key]
command=~/.config/i3blocks/Blocks/key_l.sh
interval=once
color=#33ff33
##### Mocp
[Mocp]
command=~/.config/i3blocks/Blocks/mocp.sh
interval=60
color=#66CCFF
##### Conexión Ethernet
[Ether]
command=~/.config/i3blocks/Blocks/net.sh -e
interval=10
color=#CC99FF
##### Conexión Wifi
[Ether]
command=~/.config/i3blocks/Blocks/net.sh -w
interval=10
color=#CC99FF
##### Touchpad
[Touchpad]
command=~/.config/i3blocks/Blocks/touchpad.sh
interval=10
color=#4d4dff
##### Actualizaciones
[Update]
command=~/.config/i3blocks/Blocks/update.sh
interval=600
color=#FFCC99
##### Tiempo de uso
[Uptime]
command=~/.config/i3blocks/Blocks/uptime.sh
interval=60
color=#FFCC00
##### Idioma del sistema
[Long]
command=~/.config/i3blocks/Blocks/long.sh
interval=600
color=#FFFF99
### [!] NOTA:
Necesitarás intalar el paquete fonts awesome

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 872 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 805 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 847 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1003 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 505 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1,31 +0,0 @@
#!/bin/sh
## Script de notificación para la bateria
restante=$(acpi | awk '{print $5}')
#estado=$(acpi | awk '{print $3}' | cut -d"," -f1)
estado=$(cat /sys/class/power_supply/BAT1/capacity_level)
porcentaje=$(cat /sys/class/power_supply/BAT1/capacity)
# Si el porcentaje de bateria es menor o igual a 30 y mayor a 25, mostrar el mensaje
if [ "$porcentaje" -le 30 ] && [ "$porcentaje" -gt 25 ]; then
notify-send --urgency=normal -i $HOME/.icons/status/battery_low.png "Conectar el cargador" "Tiempo de bateria disponible $restante"
fi
# Si el porcentaje de bateria es igual o menor a 25, mostrar el siguiente mensaje y...
# 1. Si se conecta el cargador no suspender el equipo
# 2. Si no se conecta el cargador suspender el equipo
if [ "$porcentaje" -le 25 ]; then
notify-send --urgency=critical -i $HOME/.icons/status/battery_critical.png "Batería crítica" "Activando modo de ahorro de \nenergia en 30 segundos..."
sleep 30 &&
if [ "$estado" = "Charging" ]; then
notify-send --urgency=normal "Cargando bateria"
else
doas zzz
fi
fi
# Si el porcentaje de la bateria es igual al 100% mostrar el siguiente mensaje
#if [ "$porcentaje" -eq "100" ]; then
# notify-send --urgency=normal -i $HOME/.icons/status/battery_charged.png "Bateria cargada" "Puede desconectar el cargador"
#fi

View File

@ -1,6 +1,12 @@
#!/bin/sh
# Script para buscar enlaces simbólicos rotos en el directorio actual
# Si se desea buscar en todo el sistema cambiar ./ por /
#
# Dependencias: find
#
# Autor: O. Sánchez <o-sanchez@linuxmail.org>
set -e # Si hay un error, salir inmediatamente
find ./ -type l > tmp
while IFS= read -r file

19
varios/check_script.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
# Script que revisa la sintaxis en busca de bashismos y que sea compatible con el estándar POSIX
#
# Dependencias: shellcheck, checkbashisms
#
# Uso:
# check_script filepath
#
# Shell: POSIX compliant
# Autor: O. Sánchez <o-sanchez@linuxmail.org>
if ! command -v shellcheck >/dev/null; then
printf '%b' "\033[31;5m[ERROR] Instale el paquete 'shellcheck'\033[0m\n"
elif ! command -v checkbashisms >/dev/null; then
printf '%b' "\033[31;5m[ERROR] Instale el paquete 'checkbashisms'\033[0m\n"
fi
glibc shellcheck "$1"
checkbashisms "$1"

View File

@ -1,4 +0,0 @@
#!/bin/sh
CIUDAD=foo
CLIMA=$(curl -s wttr.in/$CIUDAD?format=1 | grep -o "[0-9].*")
echo " $CLIMA" > /tmp/weather

9
varios/clima.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
# Scrip que muestra la temperatura climática de la ciudad especificada
# Dependencias: curl
#
# Autor: O. Sánchez <o-sanchez@linuxmail.org>
CIUDAD=foo
CLIMA=$(curl -s wttr.in/$CIUDAD?format=1 | grep -o "[0-9].*")
echo "$CLIMA" > /tmp/weather

View File

@ -1,51 +0,0 @@
#!/bin/sh
# Colores tipo bold
printf '%b' "\033[30;1mGris\033[0m\n"
printf '%b' "\033[31;1mRojo\033[0m\n"
printf '%b' "\033[32;1mVerde\033[0m\n"
printf '%b' "\033[33;1mAmarillo\033[0m\n"
printf '%b' "\033[34;1mAzul\033[0m\n"
printf '%b' "\033[35;1mRosa\033[0m\n"
printf '%b' "\033[36;1mAqua\033[0m\n"
printf '%b' "\033[37;1mBlanco\033[0m\n"
printf "\n"
# Colores claros
printf '%b' "\033[31;2mRojo\033[0m\n"
printf '%b' "\033[32;2mVerde\033[0m\n"
printf '%b' "\033[33;2mAmarillo\033[0m\n"
printf '%b' "\033[34;2mAzul\033[0m\n"
printf '%b' "\033[35;2mRosa\033[0m\n"
printf '%b' "\033[36;2mAqua\033[0m\n"
printf '%b' "\033[37;2mBlanco\033[0m\n"
printf "\n"
# Colores letra cursiva
printf '%b' "\033[31;3mRojo\033[0m\n"
printf '%b' "\033[32;3mVerde\033[0m\n"
printf '%b' "\033[33;3mAmarillo\033[0m\n"
printf '%b' "\033[34;3mAzul\033[0m\n"
printf '%b' "\033[35;3mRosa\033[0m\n"
printf '%b' "\033[36;3mAqua\033[0m\n"
printf '%b' "\033[37;3mBlanco\033[0m\n"
printf "\n"
# Colores letra subrayada
printf '%b' "\033[31;4mRojo\033[0m\n"
printf '%b' "\033[32;4mVerde\033[0m\n"
printf '%b' "\033[33;4mAmarillo\033[0m\n"
printf '%b' "\033[34;4mAzul\033[0m\n"
printf '%b' "\033[35;4mRosa\033[0m\n"
printf '%b' "\033[36;4mAqua\033[0m\n"
printf '%b' "\033[37;4mBlanco\033[0m\n"
printf "\n"
# Colores y texto parpadeando
printf '%b' "\033[31;5mRojo\033[0m\n"
printf '%b' "\033[32;5mVerde\033[0m\n"
printf '%b' "\033[33;5mAmarillo\033[0m\n"
printf '%b' "\033[34;5mAzul\033[0m\n"
printf '%b' "\033[35;5mRosa\033[0m\n"
printf '%b' "\033[36;5mAqua\033[0m\n"
printf '%b' "\033[37;5mBlanco\033[0m\n"

View File

@ -9,6 +9,8 @@
#
# If there is already a running instance, user will be prompted to end it.
RES=$(sed 's/,/x/g' /sys/class/graphics/fb?/virtual_size)
updateicon() { \
echo "$1" > /tmp/recordingicon
pkill -RTMIN+9 "${STATUSBAR:?}"
@ -31,13 +33,13 @@ screencast() { \
ffmpeg -y \
-f x11grab \
-framerate 24 \
-s $(xdpyinfo | grep dimensions | awk '{print $2;}') \
-i $DISPLAY \
# -f alsa -i default \
-f sndio -i snd/0 \
-s "$RES" \
-i "$DISPLAY" \
-f alsa -i default \
# -f sndio -i snd/0 \
-r 24 -async 1 -vsync -1 \
-c:v libx264rgb -crf 0 -preset ultrafast -c:a aac \
# -preset ultrafast -c:a libvorbis \
-preset ultrafast -c:a libvorbis \
"$HOME/screencast-$(date '+%y%m%d-%H%M%S').mkv" &
echo $! > /tmp/recordingpid
updateicon "⏺️🎙️"
@ -47,8 +49,8 @@ screencastmobile() { \
ffmpeg -y \
-f x11grab \
-framerate 60 \
-s $(xdpyinfo | grep dimensions | awk '{print $2;}') \
-i $DISPLAY \
-s "$RES" \
-i "$DISPLAY" \
-f alsa -i default \
-r 30 \
-c:v libx264 -profile:v baseline -level 3.0 -pix_fmt yuv420p -loglevel panic -c:a aac \
@ -59,8 +61,8 @@ screencastmobile() { \
video() { ffmpeg \
-f x11grab \
-s $(xdpyinfo | grep dimensions | awk '{print $2;}') \
-i $DISPLAY \
-s "$RES" \
-i "$DISPLAY" \
-c:v libx264 -qp 0 -r 30 \
"$HOME/video-$(date '+%y%m%d-%H%M%S').mkv" &
echo $! > /tmp/recordingpid
@ -71,8 +73,8 @@ videomobile() { \
ffmpeg -y \
-f x11grab \
-framerate 60 \
-s $(xdpyinfo | grep dimensions | awk '{print $2;}') \
-i $DISPLAY \
-s "$RES" \
-i "$DISPLAY" \
-r 30 \
-c:v libx264 -profile:v baseline -level 3.0 -pix_fmt yuv420p -loglevel panic\
"$HOME/video-$(date '+%y%m%d-%H%M%S').mp4" &
@ -108,7 +110,7 @@ audio() { \
}
askrecording() { \
choice=$(printf "screencast\\nvideo\\naudio\\nwebcam\\nscreencastmobile\\nvideomobile" | dmenu -i -sb "#4D4270" -p "Seleccione el modo de grabación:")
choice=$(printf "screencast\\nwebcam\\nscreencastmobile\\nvideomobile" | dmenu -i -sb "#4D4270" -p "Seleccione el modo de grabación:")
case "$choice" in
screencast) screencast;;
audio) audio;;

View File

@ -9,7 +9,7 @@
# do_script filepath
#
# Shell: POSIX compliant
# Autor: Tuxliban Torvalds <o-sanchez@linuxmail.org>
# Autor: O. Sánchez <o-sanchez@linuxmail.org>
# Validar que el archivo proporcionado como argumento existe y es válido
if [ ! -f "$1" ]; then

View File

@ -4,7 +4,7 @@
# Dependencias xelatex, pandoc
#
# Shell: POSIX compliant
# Autor: Tuxliban Torvalds <o-sanchez@linuxmail.org>
# Autor: O. Sánchez <o-sanchez@linuxmail.org>
# Nombre del script usando la sustitución de parámetros
@ -20,7 +20,7 @@ elif ! command -v pandoc > /dev/null; then
fi
ayuda() {
cat << EOF
printf %s "\
Convierte documentos docx a formato PDF.
Uso: $script <arg> <directorio o archivo>
@ -28,7 +28,7 @@ Uso: $script <arg> <directorio o archivo>
$script --conv /path/foo.docx Convierte archivo especificado
$script -c /path/ Convierte archivos compatibles del directorio especificado
EOF
"
}
case $1 in

View File

@ -1,2 +0,0 @@
#!/bin/sh
aplay "$HOME/Dropbox/Gitea/linux_dots/config/dunst/beep.wav"

2
varios/dunst_sound.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
aplay "$HOME/Dropbox/Gitea/linux_dots/home/config/dunst/beep.wav"

View File

@ -6,7 +6,7 @@
# escript filepath
#
# Shell: POSIX compliant
# Autor: Tuxliban Torvalds <o-sanchez@linuxmail.org>
# Autor: O. Sánchez <o-sanchez@linuxmail.org>
# Buscar el archivo en el PATH del sistema
FILE_PATH=$(command -v "$1" 2>/dev/null)

6
varios/facecam.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
# Abre una ventana de streaming de la cámara web.
# Requiere de ffplay (dependencia de ffmpeg)
ffplay -i /dev/video0

View File

@ -1,13 +1,19 @@
#!/bin/sh
# Script que muestra notificaciones de paquetes nuevos en el repositorio remoto,
# actualizaciones remotas y actualizaciones disponibles para el sistema
# actualizaciones remotas y actualizaciones disponibles para el sistema.
#
# Dependencias: rstail
#
# Autor: O. Sánchez <o-sanchez@linuxmail.org>
if command -v rsstail; then
rsstail -1 -u https://github.com/void-linux/void-packages/commits/master.atom > /tmp/feed
updatedpkgs="$(grep -E "Update|update" /tmp/feed | wc -l)"
newpkgs="$(grep -E "New|new" /tmp/feed | wc -l)"
sysupdates="$(xbps-install -Mnu | wc -l)"
if ! command -v rsstail >/dev/null; then
printf "\033[31;5m[ERROR] Este script requiere del paquete: 'rsstail'\033[0m\n"
exit 1;
elif command -v rsstail >/dev/null; then
rsstail -1 -u https://github.com/void-linux/void-packages/commits/master.atom > /tmp/feed
updatedpkgs="$(grep -E "Update|update" /tmp/feed | wc -l)"
newpkgs="$(grep -E "New|new" /tmp/feed | wc -l)"
sysupdates="$(xbps-install -Mnu | wc -l)"
# Notificación emergente
notify-send --urgency=critical """CAMBIOS EN EL REPOSITORIO:
@ -27,10 +33,4 @@ printf "\n"
printf "\033[32;1mACTUALIZACIONES DE SISTEMA:\033[0m\n"
printf "\033[33;5m Disponible actualmente: \033[0m"${sysupdates}
printf "\n"
# En caso de existir errores
elif ! command -v rsstail; then
printf "\033[31;5m[ERROR] Este script requiere del paquete: 'rsstail'\033[0m\n"
exit 0;
fi

View File

@ -5,9 +5,10 @@
# 3 - Operación exitosa, pero no se seleccionó un archivo
#
# Shell: POSIX compliant
# Autor: Tuxliban Torvalds <o-sanchez@linuxmail.org>
# Autor: O. Sánchez <o-sanchez@linuxmail.org>
_PATH="$HOME"
#_PATH="$HOME"
_PATH="$PWD"
book=$(find "$_PATH" -name '*.pdf' -printf '%f\n' | dmenu -l 10 -p "Library")
_book=$(find "$_PATH" -name "$book")

6
varios/fstrim.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
# Script para darle mantemiento al SSD
#doas fstrim /
#doas fstrim --quiet-unsupported /home
doas fstrim --all || true

7
varios/get_info.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
## Scrip para obtener información de las ventanas activas: class, instance
## Dependencias xprop
xprop | awk '
/^WM_CLASS/{sub(/.* =/, "instance:"); sub(/,/,"\nclass:"); print}
/^WN_NAME/{sub(/.* =/, "title:"); print}'

View File

@ -4,7 +4,7 @@
# Dependencias: moc
#
# Shell: POSIX compliant
# Autor: Tuxliban Torvalds <o-sanchez@linuxmail.org>
# Autor: O. Sánchez <o-sanchez@linuxmail.org>
if [ "$(mocp -Q %state)" != "STOP" ];then
SONG=$(mocp -Q %song)

View File

@ -1,5 +1,5 @@
#!/bin/sh
# V0.3.1
# V0.3.2
# Script para descargar una lista personalizada con direcciones para bloquearlas
# a través del fichero hosts. Para automatizar este proceso se recomienda crear
# una tarea (crontab) y ajustarla a las necesidades del usuario (diario, semanal
@ -7,8 +7,7 @@
#
# Dependencias: dzen2, wget
#
# Shell: POSIX compliant
# Autor: Tuxliban Torvalds <o-sanchez@linuxmail.org>
# Autor: O. Sánchez <o-sanchez@linuxmail.org>
msg() {
dzen2 -p '10' -fn 'JetBrains Mono:size=8:style=bold' -ta '5' \
@ -16,7 +15,7 @@ msg() {
}
which_sudo() {
if [ "$(id -u)" = "0" ]; then
if [ "$(id -u)" -eq 0 ]; then
return
elif command -v sudo >/dev/null && sudo -l | grep -q -e ' ALL$' -e xbps-install; then
echo sudo
@ -31,17 +30,20 @@ SUDO=$(which_sudo)
# Realizar copia de seguridad del fichero hosts en caso de no existir
if [ ! -f /etc/hosts.bak ]; then
printf '%b' "\033[32;1mCreando copia de seguridad del fichero hosts...\033[0m\n";
$SUDO cp /etc/hosts /etc/hosts.bak && sleep 1s; printf "\033[33;1mCopia finalizada\033[0m\n"
printf '%b' "\033[32;1mCreando copia de seguridad del fichero hosts...\033[0m\n"
$SUDO cp /etc/hosts /etc/hosts.bak
printf "\033[33;1mCopia finalizada\033[0m\n"
else
printf '%b' "\033[35;5mYa existe copia de seguridad del fichero hosts\033[0m\n"
fi
# Descargar actualización más reciente del fichero hosts
printf '%b' "\033[32;1mDescargando y copiando lista actualizada para fichero hosts...\033[0m\n" &&
wget -O /tmp/hosts http://sbc.io/hosts/alternates/fakenews-gambling-porn/hosts && "$HOME"/.local/bin/custom_sites
$SUDO mv /tmp/hosts /etc/hosts && "$HOME"/.local/bin/dunst_sound &
printf '%b' "\033[32;1mDescargando y copiando lista actualizada para fichero hosts...\033[0m\n"
wget -O /tmp/hosts http://sbc.io/hosts/alternates/fakenews-gambling-porn/hosts
"$HOME"/.local/bin/custom_sites
$SUDO mv /tmp/hosts /etc/hosts
"$HOME"/.local/bin/dunst_sound 2>/dev/null
# Notificacion de actualizacion del fichero
printf '%b' "\033[36;1mFichero hosts actualizado.\033[0m\n";
printf '%b' "\033[36;1mFichero hosts actualizado.\033[0m\n"
printf '%s\n' "Lista de fichero hosts actualizado" | msg &

0
varios/i3blocks/Arch/bat.sh Executable file → Normal file
View File

0
varios/i3blocks/Arch/cpu.sh Executable file → Normal file
View File

0
varios/i3blocks/Arch/date.sh Executable file → Normal file
View File

0
varios/i3blocks/Arch/disk.sh Executable file → Normal file
View File

0
varios/i3blocks/Arch/focus.sh Executable file → Normal file
View File

0
varios/i3blocks/Arch/key_l.sh Executable file → Normal file
View File

0
varios/i3blocks/Arch/lang.sh Executable file → Normal file
View File

0
varios/i3blocks/Arch/mem.sh Executable file → Normal file
View File

0
varios/i3blocks/Arch/mocp.sh Executable file → Normal file
View File

0
varios/i3blocks/Arch/mpd.sh Executable file → Normal file
View File

0
varios/i3blocks/Arch/net.sh Executable file → Normal file
View File

0
varios/i3blocks/Arch/temp.sh Executable file → Normal file
View File

0
varios/i3blocks/Arch/touchpad.sh Executable file → Normal file
View File

0
varios/i3blocks/Arch/trash.sh Executable file → Normal file
View File

0
varios/i3blocks/Arch/update.sh Executable file → Normal file
View File

0
varios/i3blocks/Arch/uptime.sh Executable file → Normal file
View File

0
varios/i3blocks/Arch/vol.sh Executable file → Normal file
View File

View File

@ -1,11 +1,11 @@
#!/bin/sh
# v0.2
# v0.3
# Dependencias:ImageMagick, xclip, dzen2, xdotool
#
# Shell: POSIX compliant
# Autor: Tuxliban Torvalds <o-sanchez@linuxmail.org>
# Autor: O. Sánchez <o-sanchez@linuxmail.org>
: "${script:="${0##*/}"}"
script="${0##*/}"
DIR="$HOME"/Datos/Capturas
DATE="$(date +%Y%m%d-%H%M%S)"
@ -36,7 +36,7 @@ elif ! command -v xdotool > /dev/null; then
fi
ayuda() {
cat << EOF
printf %s "\
Script para realizar capturas de pantalla utilizando ImageMagick.
Modo de uso:
@ -49,7 +49,7 @@ Modo de uso:
-F Guardar captura de pantalla de ventana activa en el disco duro
--help | -h Mostrar este mensaje de ayuda
EOF
"
}
msg() {
@ -68,25 +68,19 @@ case "$1" in
import -window "$(xdotool getwindowfocus)" png:- | xclip -t 'image/png' -selection 'clipboard' -i
;;
-g)
if [ ! -d "$DIR" ]; then
mkdir "$DIR"
fi
[ ! -d "$DIR" ] && mkdir "$DIR"
import -format png -window root "$DIR/$DATE.png"
"$HOME"/.local/bin/dunst_sound
printf '%s\n' "CAPTURA DE PANTALLA" "Guardando en: ~/Datos/Capturas" | msg
;;
-S)
if [ ! -d "$DIR/Select" ]; then
mkdir -p "$DIR/Select"
fi
[ ! -d "$DIR/Select" ] && mkdir -p "$DIR/Select"
sleep 1 && import -format png "$DIR/Select/select-$DATE.png"
"$HOME"/.local/bin/dunst_sound
printf '%s\n' "ÁREA SELECCIONADA" "Guardando en: ~/Datos/Capturas/select" | msg
;;
-F)
if [ ! -d "$DIR/Select" ]; then
mkdir -p "$DIR/Select"
fi
[ ! -d "$DIR/Select" ] && mkdir -p "$DIR/Select"
import -window "$(xdotool getwindowfocus)" -format png "$DIR/Select/window-$DATE.png"
;;
--help|-h|*)

36
varios/keyboard.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/sh
# Dependencias: xinput
#
# Shell: POSIX compliant
# Autor: O. Sánchez <o-sanchez@linuxmail.org>
script="${0##*/}"
ayuda(){
printf %s "\
Script para desactivar teclado interno en portátiles mientras se está en el servidor gráfico.
Uso: $script [arg]
Ejemplo:
$script on Activa teclado interno
$script off Desactiva teclado interno
$script --help, -h Muestra este mensaje de ayuda
"
}
# Salir si existe un error
set -e
ID=$(xinput --list | awk '/Translated/ {print $7}' | cut -d '=' -f 2)
case "$1" in
on)
xinput set-int-prop "$ID" "Device Enabled" 8 1
;;
off)
xinput set-int-prop "$ID" "Device Enabled" 8 0
;;
--help|-h|*)
ayuda
esac

137
varios/ksh/dmenurecord.ksh Executable file
View File

@ -0,0 +1,137 @@
#!/bin/ksh
# Usage:
# `$0`: Ask for recording type via dmenu
# `$0 screencast`: Record both audio and screen
# `$0 video`: Record only screen
# `$0 audio`: Record only audio
# `$0 kill`: Kill existing recording
#
# If there is already a running instance, user will be prompted to end it.
read -r RES < /sys/class/graphics/fb0/virtual_size
updateicon() { \
print "$1" > /tmp/recordingicon
pkill -RTMIN+9 "${STATUSBAR:?}"
}
killrecording() {
recpid="$(cat /tmp/recordingpid)"
# kill with SIGTERM, allowing finishing touches.
kill -15 "$recpid"
rm -f /tmp/recordingpid
updateicon ""
pkill -RTMIN+9 "${STATUSBAR:?}"
# even after SIGTERM, ffmpeg may still run, so SIGKILL it.
sleep 3
kill -9 "$recpid"
exit
}
screencast() { \
ffmpeg -y \
-f x11grab \
-framerate 24 \
-s "${RES/,/x}" \
-i "$DISPLAY" \
-f alsa -i default \
# -f sndio -i snd/0 \
-r 24 -async 1 -vsync -1 \
-c:v libx264rgb -crf 0 -preset ultrafast -c:a aac \
-preset ultrafast -c:a libvorbis \
"$HOME/screencast-$(date '+%y%m%d-%H%M%S').mkv" &
print $! > /tmp/recordingpid
updateicon "⏺️🎙️"
}
screencastmobile() { \
ffmpeg -y \
-f x11grab \
-framerate 60 \
-s "${RES/,/x}" \
-i "$DISPLAY" \
-f alsa -i default \
-r 30 \
-c:v libx264 -profile:v baseline -level 3.0 -pix_fmt yuv420p -loglevel panic -c:a aac \
"$HOME/screencast-$(date '+%y%m%d-%H%M%S').mp4" &
print $! > /tmp/recordingpid
updateicon "⏺️🎙️"
}
video() { ffmpeg \
-f x11grab \
-s "${RES/,/x}" \
-i "$DISPLAY" \
-c:v libx264 -qp 0 -r 30 \
"$HOME/video-$(date '+%y%m%d-%H%M%S').mkv" &
print $! > /tmp/recordingpid
updateicon "⏺️"
}
videomobile() { \
ffmpeg -y \
-f x11grab \
-framerate 60 \
-s "${RES/,/x}" \
-i "$DISPLAY" \
-r 30 \
-c:v libx264 -profile:v baseline -level 3.0 -pix_fmt yuv420p -loglevel panic\
"$HOME/video-$(date '+%y%m%d-%H%M%S').mp4" &
print $! > /tmp/recordingpid
updateicon "⏺️🎙️"
}
webcamhidef() { ffmpeg \
-f v4l2 \
-i /dev/video0 \
-video_size 1920x1080 \
"$HOME/webcam-$(date '+%y%m%d-%H%M%S').mp4" &
print $! > /tmp/recordingpid
updateicon "🎥"
}
webcam() { ffmpeg \
-f v4l2 \
-i /dev/video0 \
-video_size 640x480 \
"$HOME/webcam-$(date '+%y%m%d-%H%M%S').mp4" &
print $! > /tmp/recordingpid
updateicon "🎥"
}
audio() { \
ffmpeg \
-f alsa -i default \
-c:a flac \
"$HOME/audio-$(date '+%y%m%d-%H%M%S').mp4" &
print $! > /tmp/recordingpid
updateicon "🎙️"
}
askrecording() { \
choice=$(printf "screencast\\nwebcam\\nscreencastmobile\\nvideomobile" | dmenu -i -sb "#4D4270" \
-p "Seleccione el modo de grabación:")
case "$choice" in
screencast) screencast;;
audio) audio;;
video) video;;
webcam) webcam;;
screencastmobile) screencastmobile;;
videomobile) videomobile;;
esac
}
asktoend() { \
response=$(printf "No\\nSí" | dmenu -i -sb "#4D4270" -p "Grabación activa.¿Desea finalizar?") &&
[ "$response" = "Sí" ] && killrecording
}
case "$1" in
screencast) screencast;;
audio) audio;;
video) video;;
kill) killrecording;;
*) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording;;
esac

36
varios/ksh/hosts.ksh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/ksh
# V0.4
# Script para descargar una lista personalizada con direcciones para bloquearlas
# a través del fichero hosts. Para automatizar este proceso se recomienda crear
# una tarea (crontab) y ajustarla a las necesidades del usuario (diario, semanal
# mensual, etc)
#
# Dependencias: dzen2, wget
#
# Autor: Tuxliban Torvalds <o-sanchez@linuxmail.org>
function msg {
dzen2 -p '10' -fn 'JetBrains Mono:size=8:style=bold' -ta '5' \
-w '260' -x '1100' -y '25'
}
# which_sudo es una función personalizada de ksh
SUDO=$(which_sudo)
# Realizar copia de seguridad del fichero hosts en caso de no existir
if [[ ! -f /etc/hosts.bak ]]; then
printf '%b' "\033[32;1mCreando copia de seguridad del fichero hosts...\033[0m\n"
$SUDO cp /etc/hosts /etc/hosts.bak
printf "\033[33;1mCopia finalizada\033[0m\n"
else
printf '%b' "\033[35;5mYa existe copia de seguridad del fichero hosts\033[0m\n"
fi
# Descargar actualización más reciente del fichero hosts
printf '%b' "\033[32;1mDescargando y copiando lista actualizada para fichero hosts...\033[0m\n"
$SUDO wget -O /etc/hosts http://sbc.io/hosts/alternates/fakenews-gambling-porn/hosts
"$HOME"/.local/bin/dunst_sound 2> /dev/null
# Notificacion de actualizacion del fichero
printf '%b' "\033[36;1mFichero hosts actualizado.\033[0m\n"
printf '%s\n' "Lista de fichero hosts actualizado" | msg &

30
varios/ksh/kbasename.ksh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/ksh
#
# Versión Korn Shell de basename
#
# Comprobar argumentos
if (($# == 0 || $# > 2 )); then
printf %s "\
Uso: ${0##*/} string [sufijo]
Ejemplos:
${0##*/} /path/foo.xyz
foo.xyz\n
${0##*/} /path/foo .xyz
foo
"
exit 1
fi
# Obtener el nombre base
BASE=${1##*/}
# Ver si se ha dado el argumento sufijo
if (($# > 1 )); then
# Mostrar nombre base sin sufijo
print ${BASE%$2}
else
# Mostrar nombre base
print $BASE
fi

33
varios/ksh/kbattery.ksh Executable file
View File

@ -0,0 +1,33 @@
#!/bin/ksh
#
# Códigos de salida
# 0 Éxito (batería baja)
# 3 Suficiente bateria
#
# Dependencias: dzen2
#
# Autor: Tuxliban Torvalds <o-sanchez@linuxmail.org>
read -r capacity < /sys/class/power_supply/BAT0/capacity
read -r status < /sys/class/power_supply/BAT0/status
function dep {
if ! command -v dzen2 >/dev/null; then
printf '%b\n' "Dependencia no satisfecha:\n\tInstale dzen2\n"
exit 1
fi
}
function msg {
dzen2 -p -fn 'JetBrains Mono:size=8:style=bold' -ta 5 \
-w 260 -x 1100 -y 25
}
if [[ "$status" == "Discharging" ]]; then
if (( capacity <= 25 )); then
"$HOME"/Dropbox/Gitea/scripts/varios/dunst_sound 2> /dev/null
printf '%s\n' "Batería baja: $capacity%, conectar el cargador" | msg &
exit 0
fi
fi
exit 3

28
varios/ksh/kcat.ksh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/ksh
#
# Version Korn Shell de cat
#
# Comprobar uso
if (($# < 1)); then
print "Uso: ${0##*/} <archivo> ..."
exit 1
fi
# Procesar cada fichero
while (($# > 0)); do
# Asegurarse de que el archivo exista
if [[ ! -f $1 ]]; then
print "$1: Inexistente o no accesible"
else
# Abrir archivo de entrada
exec 0<$1
while read LINE; do
# Visualización de salida
print $LINE
done
fi
# Obtener el argumento del siguiente archivo
shift
done

12
varios/ksh/kdirname.ksh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/ksh
#
# Versión Korn Shell de dirname
#
# Comprobar argumentos
if (($# ==0 || $# > 1)); then
print "Uso: ${0##*/} string"
exit 1
fi
# Obtener el nombre del directorio
print ${1%/*}

94
varios/ksh/kdocx2.ksh Executable file
View File

@ -0,0 +1,94 @@
#!/bin/ksh
# Script para convertir documentos de word a PDF o a texto plano usando pandoc
#
# NOTA: Este script hace uso de la sustitución de parámetros para obtener el nombre del archivo (basename)
# y de su respectivo path (dirname). Se aprovecha esta funcionalidad del shell para evitar hacer uso de
# comandos externos.
# Este script utiliza en su mayoría el parámetro $2 el cual puede ser el archivo que se desea convertir o
# también puede ser el directorio donde se encuentran los archivos que se convertirán a formato pdf.
#
# Equivalencias sustituyendo al parámetro $2:
# 1. extensión: ${2##*.}
# 2. dirname: ${2%/*}
# 3. basename: ${2##*/}
# 4. pathfile sin extensión: ${file%.*}
#
# Dependencias lualatex, pandoc
#
# Autor: Tuxliban Torvalds <o-sanchez@linuxmail.org>
# Nombre del script usando la sustitución de parámetros
script="${0##*/}"
# Revisar que las dependencias estén instaladas
if ! command -v lualatex > /dev/null; then
print "Dependencia lualatex no encontrada en el sistema, instalándola..."
doas xbps-install -Sy texlive-LuaTeX
elif ! command -v pandoc > /dev/null; then
print "Dependencia pandoc no encontrada en el sistema, instalándola..."
doas xbps-install -Sy pandoc
fi
function ayuda {
printf %s "\
Nombre: $script
Propósito: Convertir documentos docx a formato PDF o texto plano (txt)
Autor: Tuxliban Torvalds <o-sanchez@linuxmail.org>
Versión: 1.0 (27/04/2023)
Uso: $script <arg> <directorio o archivo>
--pdf | -p Convierte archivo(s) a formato PDF
--txt | -t Convierte archivo(s) a texto plano
--help | -h Mustra este mensaje de ayuda
EJEMPLOS: $script --pdf /path/foo.docx Convierte archivo especificado
$script -t /path/ Convierte archivos compatibles del directorio especificado a texto plano
"
}
case $1 in
--pdf|-p)
# Si el segundo argumento existe y tiene terminación docx, realizar la conversión del documento
# a archivo tipo PDF
if [[ -f $2 && ${2##*.} == "docx" ]]; then
printf '%s\n' "Convirtiendo $FILENAME a formato PDF..."
pandoc "$2" -V geometry:"top=2cm, bottom=1.5cm, left=2.4cm, right=2.4cm" \
--pdf-engine=lualatex -o ${2%.*}.pdf
exit 0
# Comprobar que el segundo argumento exista y que se trate de un directorio.
elif [[ -d $2 ]]; then
# Si en el directorio hay archivos con extensión tipo .docx, convertirlos a archivo tipo PDF
for file in "$2"*.docx; do
[[ -f $file ]] || continue
printf '%s\n' "Convirtiendo ${file##*/} a formato PDF..."
pandoc "$file" -V geometry:"top=2cm, bottom=1.5cm, left=2.4cm, right=2.4cm" \
--pdf-engine=lualatex -o "${file%.*}".pdf
done
exit 0
else
printf '%s' "\nERROR: el fichero o directorio no existe\n"
exit 1
fi
;;
--txt|-t)
if [[ -f $2 && ${2##*.} == "docx" ]]; then
printf '%s\n' "Convirtiendo $FILENAME a texto plano..."
pandoc -s "$2" -t plain -o "${2%.*}".txt --wrap=none
exit 0
elif [[ -d $2 ]]; then
for file in "$2"*.docx; do
[[ -f $file ]] || continue
printf '%s\n' "Convirtiendo ${file##*/} a formato texto plano..."
pandoc "$file" -t plain -o "${file%.*}".txt --wrap=none
done
exit 0
else
printf '%s' "\nERROR: el fichero o directorio no existe\n"
exit 1
fi
;;
--help|-h|*)
ayuda
esac

View File

@ -1,13 +1,12 @@
#!/bin/sh
#!/bin/ksh
# Dependencias: xinput
#
# Shell: POSIX compliant
# Autor: Tuxliban Torvalds <o-sanchez@linuxmail.org>
: "${script:="${0##*/}"}"
script="${0##*/}"
ayuda(){
cat << EOF
function ayuda {
printf %s "\
Script para desactivar teclado interno en portátiles mientras se está en el servidor gráfico.
Uso: $script [arg]
@ -16,7 +15,7 @@ Uso: $script [arg]
$script off Desactiva teclado interno
$script --help, -h Muestra este mensaje de ayuda
EOF
"
}
# Salir si existe un error

77
varios/ksh/kimage_ss.ksh Executable file
View File

@ -0,0 +1,77 @@
#!/bin/ksh
# v0.2
# Dependencias:ImageMagick, xclip, dzen2, xdotool
#
# Autor: Tuxliban Torvalds <o-sanchez@linuxmail.org>
script="${0##*/}"
DIR="$HOME"/Datos/Capturas
DATE="$(date +%Y%m%d-%H%M%S)"
SUDO=$(which_sudo)
if ! command -v import > /dev/null; then
printf '%b' "\033[31;5m[ERROR] Dependencias no satisfecha. Instalando ImageMagick...\033[0m\n"
"$SUDO" xbps-install -y ImageMagick
elif ! command -v xclip > /dev/null; then
printf '%b' "\033[31;5m[ERROR] Dependencias no satisfecha. Instalando xclip...\033[0m\n"
"$SUDO" xbps-install -y xclip
elif ! command -v dzen2 > /dev/null; then
printf '%b' "\033[31;5m[ERROR] Dependencias no satisfecha. Instalando dzen2...\033[0m\n"
"$SUDO" xbps-install -y dzen2
elif ! command -v xdotool > /dev/null; then
printf '%b' "\033[31;5m[ERROR] Dependencias no satisfecha. Instalando xdotool...\033[0m\n"
"$SUDO" xbps-install -y xdotool
fi
function ayuda {
printf %s "\
Script para realizar capturas de pantalla utilizando ImageMagick.
Modo de uso:
$script [-PsfgSFh]
-P Guardar captura de pantalla completa en el portapapeles
-s Guardar área seleccionada en el portapapeles
-f Guardar captura de pantalla de ventana activa en el portapapeles
-g Guardar captura de pantalla completa en el disco duro
-S Guardar área seleccionada en el disco duro
-F Guardar captura de pantalla de ventana activa en el disco duro
--help | -h Mostrar este mensaje de ayuda
"
}
function msg {
dzen2 -p 8 -e 'onstart=uncollapse' -fn 'JetBrains Mono:size=8:style=bold' -ta 5 \
-sa c -w 260 -x 1100 -y 25 -l 1
}
case "$1" in
-p)
import -window root png:- | xclip -t 'image/png' -selection 'clipboard' -i
;;
-s)
sleep 1 && import png:- | xclip -t 'image/png' -selection 'clipboard' -i
;;
-f)
import -window "$(xdotool getwindowfocus)" png:- | xclip -t 'image/png' -selection 'clipboard' -i
;;
-g)
[[ ! -d $DIR ]] || mkdir "$DIR"
import -format png -window root "$DIR/$DATE.png"
"$HOME"/.local/bin/dunst_sound
printf '%s\n' "CAPTURA DE PANTALLA" "Guardando en: ~/Datos/Capturas" | msg &
;;
-S)
[[ ! -d $DIR/Select ]] || mkdir -p "$DIR"/Select
sleep 1 && import -format png "$DIR/Select/select-$DATE.png"
"$HOME"/.local/bin/dunst_sound
printf '%s\n' "ÁREA SELECCIONADA" "Guardando en: ~/Datos/Capturas/select" | msg &
;;
-F)
[[ ! -d $DIR/Select ]] || mkdir -p "$DIR"/Select
import -window "$(xdotool getwindowfocus)" -format png "$DIR/Select/window-$DATE.png"
;;
--help|-h|*)
ayuda
esac

54
varios/ksh/krwallpaper.ksh Executable file
View File

@ -0,0 +1,54 @@
#!/bin/ksh
## Script que aleatoriza wallpaper
## Dependencias: ImageMagick
#
# Autor: Tuxliban Torvalds <o-sanchez@linuxmail.org>
#
# Lista de códigos de salida
# 0 - éxito
# 10 - Dependencia no satisfecha
# 11 - Wallpaper no se modificó
function deps {
if ! command -v magick >/dev/null; then
printf '%s\n' "ImageMagick no disponible, instálelo"
return 10
else
return 0
fi
}
# Obtener resolución de pantalla
read -r RES < /sys/class/graphics/fb0/virtual_size
# Path wallpapers
DIR_WALL="$HOME/Datos/Imágenes/Wallpapers"
# Obtener una lista de los archivos de imagen en el directorio de wallpapers
WALL=("$DIR_WALL"/*.{jpg,jpeg,png})
# Obtener un número aleatorio entre 0 y la cantidad de archivos de imagen en la lista
((RAND_INDEX=RANDOM % ${#WALL[@]}))
# Obtener el nombre del archivo de imagen seleccionado
RAND_IMG="${WALL[$RAND_INDEX]}"
if deps; then
# Comprobar que el archivo seleccionado exista
if [[ -f $RAND_IMG ]]; then
# Si el archivo existe, configurarlo como wallpaper
display -resize "!${RES/,/x}" -window root "$RAND_IMG"
exit 0
else
print "El archivo $RAND_IMG no existe."
if [[ ! -f $RAND_IMG ]]; then
((RAND_INDEX=RANDOM % ${#WALL[@]}))
RAND_IMG="${WALL[$RAND_INDEX]}"
display -resize "!${RES/,/x}" -window root "$RAND_IMG"
fi
exit 11
fi
else
exit 10
fi

138
varios/ksh/ksync_cloud.ksh Executable file
View File

@ -0,0 +1,138 @@
#!/bin/ksh
# v1.3
# Script para sincronizar nube remota de dropbpox
# Dependencias: rclone, rclonesync, dzen2
#
# Lista de códigos de salida
# 0 - éxito
# 9 - operación exitosa, pero no se transfirieron archivos
# 10 - error temporal de sincronización
# 11 - error por falta de conexión
# 12 - error de dependencia
# 13 - error no categorizado de otra manera
#
# Autor: Tuxliban Torvalds <o-sanchez@linuxmail.org>
set -u # salir si una variable no ha sido declarada
########## Verificar que las dependencias estén instaladas ##########
function deps {
if ! command -v rclone >/dev/null; then
printf '%b' "\033[31;5m[ERROR] Instale el paquete 'rclone'\033[0m\n"
return 12
elif ! command -v dzen2 >/dev/null; then
printf '%b' "\033[31;5m[ERROR] Instale el paquete 'dzen2'\033[0m\n"
return 12
# El cliente rclone de forma nativa ya soporta le sincronización bidirecional, por esa razón
# las siguiente líneas de código han sido comentadas.
# elif ! command -v rclonesync >/dev/null; then
# printf '%b' "\033[31;5m[ERROR] No está disponible 'rclonesync' en el sistema. Clonado \
# repositorio para instalar el ejecutable...\033[0m\n"
# git -C /tmp clone https://github.com/cjnaz/rclonesync-V2.git --depth 1
# [ -d "$HOME"/.local/bin ] || mkdir -p "$HOME/.local/bin"
# cp /tmp/rclonesync-V2/rclonesync "$HOME"/.local/bin
# export PATH="$HOME/.local/bin:$PATH"
# return 12
fi
}
########## Directorio para base de datos ##########
WORKDIR="$HOME"/.config/rclone
TMPFILE=$(mktemp /tmp/dropbox.XXXXXXXXXX)
if [[ ! -f $WORKDIR/dropbox.txt ]]; then
find "$HOME/Dropbox" -type f -exec md5sum {} \; > "$WORKDIR"/dropbox.txt
fi
########## Eliminar algún archivo residual que pudiera haber quedado ##########
for FILE in /tmp/dropbox*; do
[[ -f $FILE ]] || continue
rm "$FILE"
done
########## Sincronizar nube remota ##########
function check_diff {
find "$HOME/Datos/Dropbox" -type f -exec md5sum {} \; > "$TMPFILE"
DIFF=$(diff -q "$WORKDIR/dropbox.txt" "$TMPFILE")
if [[ -z $DIFF ]]; then
return 9
fi
}
# Rclone ya integra de forma nativa la sincronizacion bidireccional
#function sync {
# rclonesync "$HOME"/Dropbox MiDropbox: --check-access --check-filename=RCLONE_TEST \
# --filters-file "$HOME"/.config/rclone/Filtro.txt --rclone-args --copy-links \
# --multi-thread-streams=14 --transfers=14 >> "$HOME"/.config/rclone/log 2>&1
#}
#function first_sync {
# rclonesync "$HOME"/Dropbox MiDropbox: --first-sync --check-access --check-filename=RCLONE_TEST \
# --filters-file "$HOME"/.config/rclone/Filtro.txt --rclone-args --copy-links \
# --multi-thread-streams=14 --transfers=14 >> "$HOME"/.config/rclone/log 2>&1
#}
function first_sync {
/usr/bin/rclone bisync "$HOME"/Dropbox MiDropbox: --resync --check-access --check-filename=RCLONE_TEST \
--filters-file "$HOME"/.config/rclone/Filtro.txt --remove-empty-dirs --color AUTO --copy-links \
--multi-thread-streams=4 --transfers=8 --log-file "$HOME"/.config/rclone/dropbox.log 2>&1
}
function sync {
/usr/bin/rclone bisync "$HOME"/Dropbox MiDropbox: --check-access --check-filename=RCLONE_TEST \
--filters-file "$HOME"/.config/rclone/Filtro.txt --remove-empty-dirs --color AUTO --copy-links \
--multi-thread-streams=4 --transfers=8 --log-file "$HOME"/.config/rclone/dropbox.log 2>&1
}
function msg {
dzen2 -p 8 -e 'onstart=uncollapse' -fn 'JetBrains Mono:size=8:style=bold' -ta c \
-sa c -w 260 -x 1100 -y 25 -l 1
}
if deps; then
if check_diff; then
if ping -A -c 3 1.1.1.1 >/dev/null; then
if sync; then
print "Dropbox sincronizado" | msg &
print "Dropbox sincronizado"
mv "$TMPFILE" "$WORKDIR/dropbox.txt"
exit 0
else
first_sync
print "Dropbox sincronizado" | msg &
print "Dropbox sincronizado"
exit 10
fi
elif [[ $(ping -A -c 3 1.1.1.1 >/dev/null) == 1 ]]; then
printf '%s\n' "No se pudo sincronizar Dropbox" "Sin conexión a internet" | msg &
print "No se pudo sincronizar Dropbox. Sin conexión a internet\\n"
rm "$TMPFILE"
exit 11
else
rm "$TMPFILE"
printf '%s\n' "Ocurrieron errores" "Revisar el log" | msg &
print "Ocurrieron errores. Revisar el log\\n"
exit 13
fi
else
rm "$TMPFILE"
print "Operación exitosa, pero no se transfirieron archivos\\n"
exit 9
fi
fi
print "ERROR: Dependencias no satisfechas. Este script requiere tener instalado:"
#print "\\trclone\\n" "\\trclonesync\\n" "\\tdzen2\\n"
print "\\trclone\\n" "\\tdzen2\\n"
exit 12

Some files were not shown because too many files have changed in this diff Show More