2022-04-23 00:59:43 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-05-02 01:22:19 -04:00
|
|
|
REd="\e[0;31m"; GRn="\e[0;32m"; ORn="\e[33m";
|
|
|
|
FND="\e[40m"; RED="\e[1;31m"; GRN="\e[1;32m";
|
2022-05-20 21:03:56 -04:00
|
|
|
MGT="\e[1;35m"; BLU="\e[1;34m"; RST="\e[0m";
|
2022-05-02 01:22:19 -04:00
|
|
|
CYA="\e[1;36m"; CYa="\e[0;36m";
|
|
|
|
|
2022-04-23 00:59:43 -04:00
|
|
|
Caldera(){
|
|
|
|
xfce4-terminal --geometry 27x22+850+350 --hide-toolbar --hide-borders --hide-menubar \
|
|
|
|
--working-directory $HOME/Arduino/Proyectos/termoRat/scripts/ \
|
|
|
|
--execute $HOME/Arduino/Proyectos/termoRat/scripts/caldera.py
|
|
|
|
}
|
|
|
|
|
|
|
|
Termo(){
|
|
|
|
xfce4-terminal --geometry 30x24+850+350 --hide-toolbar --hide-borders --hide-menubar \
|
|
|
|
--working-directory $HOME/Arduino/Proyectos/termoRat/scripts/ \
|
|
|
|
--execute $HOME/Arduino/Proyectos/termoRat/scripts/caldera.sh
|
|
|
|
}
|
|
|
|
|
|
|
|
Neo(){
|
|
|
|
Imprime_Logos(){
|
|
|
|
printf "LOGOS: "
|
|
|
|
awk '/ascii_distro/{flag=1;next} /ascii_bold/{flag=0} flag {print}' \
|
2022-04-27 00:49:39 -04:00
|
|
|
<<< "$(neofetch --help)" | sed 's/^ */\t/'
|
2022-04-23 00:59:43 -04:00
|
|
|
}
|
|
|
|
case "${1}" in
|
|
|
|
"-h")
|
|
|
|
Imprime_Logos
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
clear && neofetch --ascii_distro "$1"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
yutu(){
|
|
|
|
local BUSQUEDA="$*"
|
|
|
|
local BUSQUEDA="${BUSQUEDA// /+}"
|
|
|
|
mpv "https://youtube.com/$(curl -s "https://vid.puffyan.us/search?q=${BUSQUEDA}" | \
|
|
|
|
grep -Eo "watch\?v=.{11}" | head -n 1)" &
|
|
|
|
}
|
|
|
|
|
2022-08-10 01:58:04 -04:00
|
|
|
ver_imgs(){
|
|
|
|
[[ -z "${@}" ]] && dir_imgs="./" || dir_imgs="${@}"
|
|
|
|
[[ ! "${dir_imgs}" =~ /$ ]] && dir_imgs+='/'
|
|
|
|
if [ -d "${dir_imgs}" ] && [ "${TERM}" = "xterm-kitty" ]; then
|
|
|
|
for imagen in $(ls "${dir_imgs}"); do
|
|
|
|
img="${dir_imgs}${imagen}"
|
|
|
|
if [ -f "${img}" ]; then
|
|
|
|
shopt -s nocasematch
|
|
|
|
if [[ "${imagen}" =~ \.(jpe?g|png|svg|webp|gif|ico|bmp|tiff?)$ ]]; then
|
|
|
|
printf 'Imagen: [%b%s%s%b]\n' "${GRn}" "${dir_imgs}" "${imagen}" "${RST}"
|
|
|
|
kitty +kitten icat "${img}"
|
|
|
|
read -p 'continuar'
|
|
|
|
else
|
|
|
|
printf 'Omitiendo extensión: [%b%s%b]\n' "${REd}" "${img}" "${RST}"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
printf 'Omitiendo directorio: [%b%s%b]\n' "${REd}" "${img}" "${RST}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
printf '\n%bDestino inexistente o terminal no es kitty%b\n' "${REd}" "${RST}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-04-23 00:59:43 -04:00
|
|
|
kaltest() {
|
|
|
|
[[ -n $1 ]] && local pmes=$1 || local pmes=0
|
|
|
|
[[ -n $2 ]] && local mesp=$2 || local mesp=$(date '+%Y')
|
|
|
|
cal -m -n $pmes -S $mesp
|
|
|
|
}
|
|
|
|
|
|
|
|
covStats(){
|
|
|
|
# Cache https
|
|
|
|
[ "$(stat -c %y ~/.cache/corona 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] &&
|
|
|
|
curl -s https://corona-stats.online?source=2 | \
|
|
|
|
sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" > ~/.cache/corona
|
|
|
|
|
|
|
|
# Estadisticas covid Chile
|
|
|
|
declare Vars
|
|
|
|
Vars="$(grep "Chile" ~/.cache/corona |
|
|
|
|
sed "s/\s*//g ; s/║//g ; s/│/;/g " |
|
|
|
|
sed "s/(CL)//g" | awk -F';' '{print $3" "$7" "$5" "$8}')"
|
2022-05-02 01:22:19 -04:00
|
|
|
Contag=$(cut -d' ' -f1 <<<${Vars})
|
|
|
|
Recupe=$(cut -d' ' -f2 <<<${Vars})
|
|
|
|
Muerte=$(cut -d' ' -f3 <<<${Vars})
|
|
|
|
Activo=$(cut -d' ' -f4 <<<${Vars})
|
2022-04-28 13:49:16 -04:00
|
|
|
Murtio="${Muerte//,/}"
|
|
|
|
Conteg="${Contag//,/}"
|
2022-05-02 01:22:19 -04:00
|
|
|
|
2022-04-23 00:59:43 -04:00
|
|
|
# Población Chile
|
|
|
|
PoblT=19678310
|
|
|
|
# Muertes
|
|
|
|
Mtota="$(python3 -c "print('{:.2f}'.format(100*$Murtio/$PoblT))")"
|
2022-05-02 01:22:19 -04:00
|
|
|
Mcont="$(python3 -c "print('{:.2f}'.format(100*$Murtio/$Conteg))")"
|
2022-04-23 00:59:43 -04:00
|
|
|
# Vista
|
2022-05-02 01:22:19 -04:00
|
|
|
printf '\n %bEstadisticas COVID %bChile 🇨🇱️ %b\n' "${GRN}" "${BLU}" "${RST}"
|
2022-05-20 21:03:56 -04:00
|
|
|
printf '%b%s%b\n' "${MGT}" " ============================" "${RST}"
|
2022-08-10 01:58:04 -04:00
|
|
|
printf ' %bMuertes totales :%b %s %s %b\n' "${RED}" "${CYA}" "${Mtota}" "%" "${RST}"
|
|
|
|
printf ' %bMuertes contagio:%b %s %s %b\n' "${REd}" "${CYa}" "${Mcont}" "%" "${RST}"
|
2022-05-20 21:03:56 -04:00
|
|
|
printf '%b%s%b\n' "${MGT}" " ----------------------------" "${RST}"
|
2022-05-02 01:22:19 -04:00
|
|
|
printf ' %bContagios : %b%s%b\n' "${GRn}" "${CYa}" "${Contag}" "${RST}"
|
|
|
|
printf ' %bActivos : %b%s%b\n' "${GRn}" "${CYa}" "${Activo}" "${RST}"
|
|
|
|
printf ' %bRecuperados : %b%s%b\n' "${GRn}" "${CYa}" "${Recupe}" "${RST}"
|
|
|
|
printf ' %bMuertes : %b%s%b\n' "${RED}" "${CYA}" "${Muerte}" "${RST}"
|
2022-05-20 21:03:56 -04:00
|
|
|
printf '%b%s%b\n' "${MGT}" " ----------------------------" "${RST}"
|
2022-05-02 01:22:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
mpvPlaylist(){
|
2022-05-20 21:03:56 -04:00
|
|
|
# alias mpvp
|
2022-05-02 01:22:19 -04:00
|
|
|
ayuda(){
|
|
|
|
while read; do
|
|
|
|
printf '%s\n' "${REPLY}"
|
|
|
|
done <<-EOF
|
|
|
|
Uso:
|
2022-05-20 21:03:56 -04:00
|
|
|
mpvp Ejecuta el script.
|
|
|
|
mpvp <link> Agrega el link a playlist.
|
|
|
|
mpvp -r, --play Reproduce playlist.
|
|
|
|
mpvp -s, --off Reproduce playlist y apaga el equipo.
|
|
|
|
mpvp -h, --help Muestra el contenido de ayuda.
|
2022-05-02 01:22:19 -04:00
|
|
|
EOF
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
playlist=$HOME/.cache/.playlist
|
|
|
|
touch $playlist
|
|
|
|
valid='(https)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]'
|
|
|
|
case ${1} in
|
|
|
|
-h|--help)
|
|
|
|
ayuda ;;
|
|
|
|
-r|--play)
|
|
|
|
printf '\n%bReproduciendo Playlist%b\n' "${GRN}" "${RST}"
|
|
|
|
mpv --playlist=$playlist --no-terminal & exit 0 ;;
|
|
|
|
-s|--off)
|
|
|
|
printf '\n%bEl equipo se apagará al finalizar la reproducción...%b\n' \
|
|
|
|
"${ORn}" "${RST}"
|
|
|
|
mpv --playlist=$playlist --no-terminal && shutdown 0 ;;
|
|
|
|
*)
|
|
|
|
if [[ -n ${1} ]]; then
|
|
|
|
[[ ${1} =~ $valid ]] && printf '%s\n' "${1}" >> $playlist ||
|
|
|
|
printf '%b Link inválido!%b\n' "${REd}" "${RST}"
|
|
|
|
exit 0
|
|
|
|
fi ;;
|
|
|
|
esac
|
|
|
|
clear
|
|
|
|
while :; do
|
|
|
|
printf '\n %bPlaylist Manager\n' "${GRN}"
|
|
|
|
printf ' %s%b\n\n' "----------------" "${RST}"
|
|
|
|
printf ' %b1) %bVer Lista%b\n' "${BLU}" "${GRn}" "${RST}"
|
|
|
|
printf ' %b2) %bAñadir link(s)%b\n' "${BLU}" "${GRn}" "${RST}"
|
|
|
|
printf ' %b3) %bReproducir lista%b\n' "${BLU}" "${GRn}" "${RST}"
|
|
|
|
printf ' %b4) %bReproducir y Apagar PC%b\n' "${BLU}" "${GRn}" "${RST}"
|
|
|
|
printf ' %b5) %bBorrar lista%b\n' "${BLU}" "${GRn}" "${RST}"
|
|
|
|
printf ' %b6) %bEditar%b\n' "${BLU}" "${GRn}" "${RST}"
|
|
|
|
printf ' %bs) %bSalir%b\n\n' "${BLU}" "${GRn}" "${RST}"
|
|
|
|
printf ' %bElige una opción :%b' "${GRN}" "${RST}"
|
|
|
|
read -p ' '
|
|
|
|
case ${REPLY} in
|
|
|
|
1)
|
|
|
|
clear
|
|
|
|
bat --style grid,numbers ~/.cache/.playlist 2>/dev/null ;;
|
|
|
|
2)
|
|
|
|
clear
|
|
|
|
printf '%bAñadir link %b(v para volver)%b\n' \
|
|
|
|
"${GRN}" "${GRn}" "${RST}"
|
|
|
|
while :; do
|
|
|
|
printf '%bLink ->%b' "${BLU}" "${RST}"
|
|
|
|
read -p ' ' LinK
|
|
|
|
case ${LinK} in
|
|
|
|
s)
|
|
|
|
exit 0 ;;
|
|
|
|
v)
|
|
|
|
mpvPlaylist ;;
|
|
|
|
*)
|
|
|
|
[[ ${LinK} =~ ${valid} ]] && printf '%s\n' "${LinK}" >> $playlist ||
|
|
|
|
printf '%b Link inválido!%b\n' "${REd}" "${RST}" ;;
|
|
|
|
esac
|
|
|
|
done ;;
|
|
|
|
3)
|
|
|
|
printf '\n%bReproduciendo Playlist%b\n' "${GRN}" "${RST}"
|
|
|
|
mpv --playlist=$playlist --no-terminal & exit 0 ;;
|
|
|
|
4)
|
|
|
|
printf '\n%bEl equipo se apagará al finalizar la reproducción...%b\n' \
|
|
|
|
"${ORn}" "${RST}"
|
|
|
|
mpv --playlist=$playlist --no-terminal && shutdown 0 ;;
|
|
|
|
5)
|
|
|
|
printf '' > $playlist && clear ;;
|
|
|
|
6)
|
|
|
|
clear; nvim $playlist ;;
|
|
|
|
s|0)
|
|
|
|
exit 0 ;;
|
|
|
|
*)
|
|
|
|
printf '%b Opción inválida!%b\n' "${REd}" "${RST}"
|
|
|
|
sleep 1.5 && clear ;;
|
|
|
|
esac
|
|
|
|
done
|
2022-04-23 00:59:43 -04:00
|
|
|
}
|
|
|
|
|
2022-05-20 21:03:56 -04:00
|
|
|
metronomo() {
|
|
|
|
wavcach=$HOME/.cache
|
|
|
|
if [ -z "${1}" ]; then
|
|
|
|
BPM=80
|
|
|
|
elif [[ -n ${1//[0-9]/} ]]; then
|
|
|
|
printf "%bDebes ingresar los BPM (10-500).%b\n" \
|
|
|
|
"${MGT}" "${RST}" && exit 1
|
|
|
|
#printf "Debes ingresar un numero entre 10 y 500.\n" && exit 1
|
|
|
|
elif [[ "${1}" -lt 501 ]] && [[ "${1}" -gt 9 ]]; then
|
|
|
|
BPM="${1}"
|
|
|
|
else
|
|
|
|
printf "%bDebes ingresar un numero entre 10 y 500.%b\n"\
|
|
|
|
"${ORn}" "${RST}" && exit 1
|
|
|
|
#printf "Debes ingresar un numero entre 10 y 500.\n" && exit 1
|
|
|
|
fi
|
|
|
|
bpm=$(echo "(60000/${BPM}/1000)" | bc -l)
|
|
|
|
if [ ! -f ${wavcach}/metro.wav ]; then
|
|
|
|
ffmpeg -f lavfi -i "sine=frequency=320:duration=0.05" -ac 2 ${wavcach}/metro.wav &>/dev/null
|
|
|
|
fi
|
|
|
|
printf '%bMetronomo a: %b%s bpm%b\n%b[Salir] %b<Ctrl>+<C>%b\n' \
|
|
|
|
"${CYA}" "${GRN}" "${BPM}" "${RST}" "${REd}" "${BLU}" "${RST}"
|
|
|
|
while :; do
|
|
|
|
aplay -q ${wavcach}/metro.wav & sleep ${bpm}
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
touch_exec(){
|
|
|
|
touch "${1}" && chmod u+x ${1} && nvim ${1}; }
|
|
|
|
|
2022-04-23 00:59:43 -04:00
|
|
|
"$@"
|