From a740804cf3ff004a0b1283d7bcedac5885f01c36 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 13 Dec 2018 13:07:39 +0100 Subject: [PATCH] Add mpc information to i3bar Signed-off-by: Knut Ahlers --- .config/i3blocks/config | 3 +++ .config/i3blocks/mpc | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100755 .config/i3blocks/mpc diff --git a/.config/i3blocks/config b/.config/i3blocks/config index 2414bf3..0805144 100644 --- a/.config/i3blocks/config +++ b/.config/i3blocks/config @@ -29,6 +29,9 @@ separator_block_width=15 markup=pango +[mpc] +interval=5 + [arch-update] interval=600 diff --git a/.config/i3blocks/mpc b/.config/i3blocks/mpc new file mode 100755 index 0000000..26e3fe4 --- /dev/null +++ b/.config/i3blocks/mpc @@ -0,0 +1,22 @@ +#!/bin/bash +set -euo pipefail + +[ $(mpc | wc -l) -eq 1 ] && { + printf '\uf9da' + exit +} + +title=$(mpc | head -n1 | tr -cd "[:print:]") +state=$(mpc | grep '^\[' | sed -E 's/^\[(.+)\].*/\1/') + +case ${state} in +playing) + printf '\uf909 %s' "${title}" + ;; +paused) + printf '\uf8e3 %s' "${title}" + ;; +*) + printf 'State: %s Title: %s' ${state} "${title}" + ;; +esac