trivial spotify script..

I use this little script for my stream set up at live.shrik3.com

It does two things:

  • print the current song, and the most recent n songs in the terminal
  • log all the played songs to a file

Note: needs spotify-cli as dependency

#!/bin/bash

clear

LOG_PATH="/PATH/TO/LOG/FILE"


INFO=$(spotifycli --status)

black=`tput setaf 0`
red=`tput setaf 1`
green=`tput setaf 2`
white_bg=`tput setab 7`
bold=`tput bold`
reset=`tput sgr0`


# spotifycli --status >> /dev/tty

tail -n 8 $LOG_PATH
echo "${black}${white_bg}${bold} >>> $(spotifycli --status) ${reset}"

while :
do 

    INFO1=$(spotifycli --status)
    if [ "$INFO" != "$INFO1" ]; then   
        clear
        printf "\n"
        tail -n 8 $LOG_PATH
        INFO=$(spotifycli --status)
        printf "\n"

        # spotifycli --status >> /dev/tty

        # echo "${red}${white_bg}${bold} >>> $(spotifycli --status) ${reset}"
        echo "${red}${bold} >>> $(spotifycli --status) ${reset}"

        spotifycli --status >> $LOG_PATH
    fi
    sleep 1


done