#!/bin/bash

dmenu="bemenu -p playlist --center --list 20 down --width-factor 0.5 --border 2 --bdr #f6c2e7"

case "$1" in
    --playlist)
        choice=$(mpc lsplaylists | $dmenu)

        if [[ -n $choice ]]; then
            mpc clear
            mpc load $choice
            mpc shuffle
            mpc next
            mpc play
        fi
        ;;
    --song)
        choice=$(mpc listall | $dmenu)
        echo $choice

        if [[ -n $choice ]]; then
            mpc add "$choice"
            mpc searchplay "$choice"
        fi
        ;;
    *)
        exit 1
        ;;
esac
