This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/.local/bin/statusbar/sb-music
2021-02-21 00:36:26 +01:00

20 lines
692 B
Bash
Executable File

#!/usr/bin/env sh
######################################################################
# @author : swytch (adapted from Luke Smith - lukesmith.xyz)
# @file : sb-music
# @license : GPLv3
# @created : Saturday Feb 13, 2021 18:05:21 CET
#
# @description : music block for dwmblocks
######################################################################
mpc="$(mpc --format "%albumartist% - %title%")"
format() { tac | sed "s/^volume:n\/a.*//g;/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/⏸/g;s/\\[playing\\].*/🎵/g" | paste -sd ' ' -;}
pgrep -f sb-mpdup >/dev/null 2>&1 || sb-mpdup >/dev/null 2>&1 &
mpc=$(echo "$mpc" | format)
[ -n "$mpc" ] && printf " %s " "$mpc"