From 707294cc42d4104ef68d01132cf972f2b01646f9 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Tue, 11 Dec 2018 18:48:46 +0000 Subject: [PATCH] Adds mpv radio block --- i3/blocks/mediaplayer | 10 ++++------ i3/blocks/mpvmediaplayer | 14 ++++++++++++++ i3/i3blocks.conf | 12 +++++++++++- 3 files changed, 29 insertions(+), 7 deletions(-) create mode 100755 i3/blocks/mpvmediaplayer diff --git a/i3/blocks/mediaplayer b/i3/blocks/mediaplayer index e87a17b3..19410b51 100755 --- a/i3/blocks/mediaplayer +++ b/i3/blocks/mediaplayer @@ -10,16 +10,16 @@ case $BLOCK_BUTTON in esac -if [ "$($COMMAND status)" = "Playing" ]; then +if [ "$($COMMAND status 2> /dev/null )" = "Playing" ]; then colour="#00FF00" else colour="#FF8000" fi -title=$($COMMAND metadata title | sed "s/\&/\&/g") -artist=$($COMMAND metadata artist | sed "s/\&/\&/g") +title=$($COMMAND metadata title 2> /dev/null | sed "s/\&/\&/g") +artist=$($COMMAND metadata artist 2> /dev/null | sed "s/\&/\&/g") -if [ "$title" != "(null)" ]; then +if [ "$title" != "" ]; then ret="$title" if [ -n "$artist" ]; then ret="$ret - $artist" @@ -28,5 +28,3 @@ if [ "$title" != "(null)" ]; then echo "$ret"; fi - - diff --git a/i3/blocks/mpvmediaplayer b/i3/blocks/mpvmediaplayer new file mode 100755 index 00000000..2316ba05 --- /dev/null +++ b/i3/blocks/mpvmediaplayer @@ -0,0 +1,14 @@ +#!/usr/bin/sh + + +socket="${SOCKET:-/tmp/mpvsocket}" + +#case $BLOCK_BUTTON in +# 1) $COMMAND previous ;; +# 3) $COMMAND next ;; +#esac + + +echo '{ "command": ["get_property_string", "filtered-metadata"] }' | socat - /tmp/mpvsocket | jq '.data' | sed 's/"{\\"icy-title\\":\\"//g' | sed 's/\\"}"//g' +echo "" +echo "#00FF00" diff --git a/i3/i3blocks.conf b/i3/i3blocks.conf index d9d49102..9e97e4d4 100644 --- a/i3/i3blocks.conf +++ b/i3/i3blocks.conf @@ -59,10 +59,20 @@ interval=5 # Supported players are: spotify, vlc, audacious, xmms2, mplayer, and others. [mediaplayer] command=~/.dotfiles/i3/blocks/mediaplayer -instance=spotify interval=2 signal=10 markup=pango +#separator=false + +# MPV Player +# +# This displays "ARTIST - SONG" if a music is playing. +# Supported players are: spotify, vlc, audacious, xmms2, mplayer, and others. +[mpvmediaplayer] +command=~/.dotfiles/i3/blocks/mpvmediaplayer +SOCKET=/tmp/mpvsocket +interval=2 +#markup=pango #[proftpstatus] #command=~/.dotfiles/i3/blocks/proftp