dotfiles

configuration files
git clone https://pi.duncano.de/git/dotfiles.git
Log | Files | Refs | README

commit 515b693e6171b456ebc1dc7d1bd469c13c6b386d
parent 9de285f8d88bf92037845396fe072ca5d4ba0d56
Author: Duncaen <mail@duncano.de>
Date:   Sat, 16 May 2015 14:14:49 +0200

New: bin/dmenu_playerctl

Diffstat:
bin/dmenu_playerctl | 30++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+), 0 deletions(-)

diff --git a/bin/dmenu_playerctl b/bin/dmenu_playerctl @@ -0,0 +1,30 @@ +#!/bin/mksh + +select_player() { + echo $1 | tr ' ' '\n' | ${DMENU} +} + +player_menu() { + PROMPT="$1:" + ARTIST=$(playerctl -p $1 metadata xesam:artist) + TITLE=$(playerctl -p $1 metadata xesam:title) + if [ -n "$ARTIST" -a -n "$TITLE" ]; then + PROMPT="$PROMPT $ARTIST - $TITLE" + fi + if [ $(playerctl -p $1 status) == "Playing" ]; then + CMDS="Pause\n" + else + CMDS="Play\n" + fi + CMDS+="Stop\nNext\nPrevious" + ret=$(echo $CMDS | ${DMENU} -p "$PROMPT" -i | tr '[A-Z]' '[a-z]') + [ $ret ] && playerctl -p $1 $ret +} + +: ${DMENU:=dmenu} +: ${PLAYER:=$(playerctl -l)} +case "$(echo ${PLAYER} | wc -w)" in + 0) echo "No player running" && exit ;; + 1) player_menu "$PLAYER" ;; + *) player_menu $(select_player "$PLAYER") ;; +esac