From a206df3ceef3132f7373c876f02f894bc23103b1 Mon Sep 17 00:00:00 2001 From: "jp.av.dev" Date: Fri, 20 May 2022 21:03:56 -0400 Subject: [PATCH] +: otros.sh funcion metronomo --- README.md | 30 ++++++++++++++++++++++++------ otros.sh | 52 +++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 65 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 4291372..7edb57d 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Selección de scripts de autoria propia - [Otros](#otros) - [Estadisticas covid Chile](#covstats) - [Mpv Playlist](#mpvplaylist) + - [Metronomo](#metronomo) - [Otras funciones](#otras-funciones) - [Lol laucher y debug](#rito-pls) @@ -232,7 +233,7 @@ Color en la consola de python con módulo **rich**. [pyRichRepl.py](./pyRichRepl # Otros -### covStats() +## covStats() Estadisticas covid Chile `./otros.sh covStats` @@ -249,20 +250,20 @@ Estadisticas covid Chile ---------------------------- ``` -### MpvPlaylist() +## MpvPlaylist() Función para administrar una 'playlist' para ser usada con [mpv](https://mpv.io) > archivo: `~/.cache/.playlist` **Uso** -ej. `alias mpvp='./otros.sh pvPlaylist'` +ej. `alias mpvp='/ruta/otros.sh mpvPlaylist'` | Orden | Detalle | | - | - | |`mpvp` | Modo interactivo | |`mpvp -h` | Mostrar ayuda | |`mpvp https://link.video`| Agregar el link a *playlist* | |`mpvp -r` | Reproducir *playlist* | -|`m̀pvp -s` | Reproducir *playlist* y apagar PC | +|`mpvp -s` | Reproducir *playlist* y apagar PC | **Modo interactivo** @@ -290,7 +291,24 @@ ej. `alias mpvp='./otros.sh pvPlaylist'` |`6`| Editar lista (neovim) | |`s`| Salir | -### Otras Funciones +## Metronomo +**Uso** +ej. `alias metro='/ruta/otros.sh metronomo'` + +Por defecto inicia a **80 bpm** +```sh +$ metro +Metronomo a: 80 bpm +[Salir] + +``` +O según argumento, ej. **120 bpm** +```sh +$ metro 120 +Metronomo a: 120 bpm +[Salir] + +``` + +## Otras Funciones | Funcion | Explicación | | - | - | @@ -303,7 +321,7 @@ Script [otros.sh](./otros.sh) ---- -# Rito pls +## Rito pls Lanza instancia de [kitty](https://sw.kovidgoyal.net/kitty/) terminal, con 3 splits (ventanas según creador). Layout tall: diff --git a/otros.sh b/otros.sh index f8dc9b0..27532ef 100755 --- a/otros.sh +++ b/otros.sh @@ -2,7 +2,7 @@ REd="\e[0;31m"; GRn="\e[0;32m"; ORn="\e[33m"; FND="\e[40m"; RED="\e[1;31m"; GRN="\e[1;32m"; -MGNT="\e[1;35m"; BLU="\e[1;34m"; RST="\e[0m"; +MGT="\e[1;35m"; BLU="\e[1;34m"; RST="\e[0m"; CYA="\e[1;36m"; CYa="\e[0;36m"; Caldera(){ @@ -71,28 +71,29 @@ covStats(){ Mcont="$(python3 -c "print('{:.2f}'.format(100*$Murtio/$Conteg))")" # Vista printf '\n %bEstadisticas COVID %bChile 🇨🇱️ %b\n' "${GRN}" "${BLU}" "${RST}" - printf '%b%s%b\n' "${MGNT}" " ============================" "${RST}" - printf ' %bMuertes totales :%b %s %b\n' "${RED}" "${CYA}" "$Mtota" "${RST}" - printf ' %bMuertes contagio:%b %s %b\n' "${REd}" "${CYa}" "$Mcont" "${RST}" - printf '%b%s%b\n' "${MGNT}" " ----------------------------" "${RST}" + printf '%b%s%b\n' "${MGT}" " ============================" "${RST}" + printf ' %bMuertes totales :%b %s %s %b\n' "${RED}" "${CYA}" "$Mtota" "%" "${RST}" + printf ' %bMuertes contagio:%b %s %s %b\n' "${REd}" "${CYa}" "$Mcont" "%" "${RST}" + printf '%b%s%b\n' "${MGT}" " ----------------------------" "${RST}" 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}" - printf '%b%s%b\n' "${MGNT}" " ----------------------------" "${RST}" + printf '%b%s%b\n' "${MGT}" " ----------------------------" "${RST}" } mpvPlaylist(){ + # alias mpvp ayuda(){ while read; do printf '%s\n' "${REPLY}" done <<-EOF Uso: - ./script mpvPlaylist Ejecuta el script. - ./script mpvPlaylist Agrega el link a playlist. - ./script mpvPlaylist -r, --play Reproduce playlist. - ./script mpvPlaylist -s, --off Reproduce playlist y apaga el equipo. - ./script mpvPlaylist -h, --help Muestra el contenido de ayuda. + mpvp Ejecuta el script. + mpvp 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. EOF exit 0 } @@ -170,4 +171,33 @@ EOF done } +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+%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}; } + "$@"