14 enero 2018

Script shell de notificaciones para el reproductor mocp, Debian.

Novedad: Agregado redimensionado de imagen.

La razón principal por la cual he escrito este sencillo script es por que mocp lo ejecuto con screen junto con irssi y mutt, la verdad screen me parece muy útil, pero cambiar de "pantalla" con tres botones para ver lo que escucho no me parece rentable.
Este scipt junto con  Resize.sh dpeneden de libnotify mat e imagemagic.
Para ejecutarlo?... bueno de eso se encarga mocp.
Paso a explicarte cómo:
Si no tienes libnotify, ejecuta lo siguiente:
# apt-get install mat imagemagick libnotify-bin
Lo siguiente será buscar un directorio para tu script, por ejemplo...:
$HOME/.moc/scripts/mocp_notify.sh
Ahora el archivo de configuración mocp:
En debian éste archivo se encuantra en:
/usr/share/doc/moc/example/config.example.gz
descomprimelo en ~/.moc con el nombre "config"
busca la linea "#OnSongChange ="
debaría quedar así:
OnSongChange = "$HOME/.moc/scripts/mocp_notify.sh %a %t %f"
Probando el resultado:
killall mocp && mocp
Cambia de canción y disfruta.
Aquí tienes un pantallazo:
https://imagebin.ca/v/3nz5mRqmdvoZ
Mi repositorio git:
https://github.com/Tarrasquero/

#!/bin/bash
LAST=$(echo "/`mocp -i|grep File:|cut -d '/' -f 2-5`")
cd "$LAST"
X=$(mat --display "$IMG0"|grep "Exif Image Width:"|cut -d ' ' -f 4)
if [ "$X" != "100" ]; then
    $HOME/.moc/scripts/Resice.sh
fi

I=$(ls|grep -i -e *.jpg)
if [ -f "$I" ]; then
    IMG0=$(find . -name '*.jpg' -or -name '*.jpeg' -or -name '*.png'|shuf -n1|xargs -0) #$(ls|grep -i -e *.jpg)  #$(ls|grep -i -e *.jpg -e *.png -e *.jpeg)
else
    IMG0=$(find . -name '*.jpg' -or -name '*.jpeg' -or -name '*.png'|cut -c2-|shuf -n1|xargs -0) 
fi

for cover in "$IMG0"; do
if [ "$IMG0" ]; then
    IMG=$(echo "$LAST/$cover")
else
    IMG=$(echo "$HOME/.moc/scripts/icon-moc.png")
fi
done

if [ "$2" ]; then
    notify-send -i "$IMG" "$1:" "$2\n$4"
else
    notify-send -i "$IMG" "$3"
fi
exit


No hay comentarios: