#!/bin/sh

madd() {
    queue="$(mpc playlist)"
    if [ -z "$queue" ]; then
        mpc insert "$filename"
        mpc play
    else
        mpc insert "$filename"
        mpc next
    fi
}

if [ -t 0 ]; then
    filename=$(mpc listall | fzf)
else
    filename=$(mpc listall | fuzzel -d -l 30)
fi

if [ -n "$filename" ]; then
    madd && notify-send "Playing $filename"
fi

