#!/usr/bin/env bash

echo "{\"show\": \"no\", \"content\": \"\"}"
while true 
do
    line=$(spt playback --status -f "%s:%a - %t" 2> /dev/null)
    IFS=':' read -ra ELS <<< "$line"
    button=${ELS[0]}
    content=${ELS[1]}
    if [ "$button" == "▶" ]; then
        echo "{\"show\": \"yes\", \"content\": \"(label :text \\\"$content\\\")\"}"
    else
        echo "{\"show\": \"no\", \"content\": \"\"}"
    fi

    sleep 1
done
