#!/usr/bin/env bash MPC="mpc --quiet -p ${1:-6600}" # max height for vertical menu height=20 DMENU() { # Vertical menu if $3 is given echo -e "$1" | dmenu -i -p "$2" ${3:+"-l" "$3"} } get_playlist() { $MPC -f "%position% - [%artist% - %album% - ]%title%" playlist } select_from() { DMENU "$1" "Select $2" $height } jump() { local playlist=$(get_playlist) local song=$(select_from "$playlist" "song") [ -n "$song" ] && $MPC play "${song%%\ *}" } load_playlist() { local pl=$(select_from "$(mpc lsplaylist)") [ -n "$pl" ] && $MPC load "$pl" } while true; do choice=$(DMENU "play\nnext\nprev\nvolume\nrepeat\nrandom\nsingle\nconsume\nlyrics\nsearch\nstatus\nclear\nload\nupdate" "Do you want to: ") case "$choice" in play) mpc toggle ;; next) mpc next ;; prev) mpc prev ;; volume) mpc volume "$(dmenu -p 'Set volume: '