29 lines
851 B
Bash
Executable File
29 lines
851 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Rutas y archivos temporales
|
|
CURRENT_TRACK_FILE="/tmp/current_track.txt"
|
|
LYRICS_FILE="/tmp/lyrics.txt"
|
|
LOG_FILE="/tmp/lyrics_error.log"
|
|
|
|
# Obtener la información actual del track usando `playerctl`
|
|
TRACK_INFO=$(playerctl metadata --format "{{artist}} - {{title}}" 2>>"$LOG_FILE")
|
|
|
|
# Validar si hay información del track
|
|
if [ -z "$TRACK_INFO" ]; then
|
|
echo "No track info available" > "$LYRICS_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
# Extraer artista y título
|
|
ARTIST=$(echo "$TRACK_INFO" | cut -d '-' -f 1 | xargs)
|
|
TITLE=$(echo "$TRACK_INFO" | cut -d '-' -f 2 | xargs)
|
|
|
|
# Usar Python para obtener las letras
|
|
python3 ~/.config/waybar/scripts/get_lyrics.py "$ARTIST" "$TITLE" > "$LYRICS_FILE"
|
|
|
|
# Verificar si el archivo de letras está vacío
|
|
if [ ! -s "$LYRICS_FILE" ]; then
|
|
echo "Letras no encontradas para $ARTIST - $TITLE" > "$LYRICS_FILE"
|
|
fi
|
|
|