21 lines
693 B
Django/Jinja
21 lines
693 B
Django/Jinja
#!/bin/sh
|
|
|
|
export MPD_HOST="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/mpd.sock"
|
|
menu="{{ launcher }} {{ dmenu_flag }}"
|
|
|
|
status=" "
|
|
if [ "$(mpc | grep -c '^\[playing]')" -eq 1 ]; then
|
|
status=" "
|
|
fi
|
|
random=""
|
|
if [ "$(mpc | grep -c ' random: on ')" -eq 1 ]; then
|
|
random=" "
|
|
fi
|
|
playlist=$(mpc playlist)
|
|
if [ "${status}" = " " ]; then
|
|
song=$(echo "${playlist}" | ${menu} -p "${status}${random} $(mpc | head -n 1){{ (launcher == 'fuzzel') | ternary(': ', '') }}")
|
|
else
|
|
song=$(echo "${playlist}" | ${menu} -p "${status}${random} Song{{ (launcher == 'fuzzel') | ternary(': ', '') }}")
|
|
fi
|
|
[ -n "${song}" ] && mpc play "$(echo "${playlist}" | awk -v s="${song}" '$0==s {print NR; exit;}')"
|