Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#!

/bin/bash
# Copyright (C) 2016 Duan Gvozdenovi

# This program is free software: you can redistribute it and/or modify


# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,


# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

if [ -z "$(pidof cmus)" ]; then


exit
fi

cmus=$(cmus-remote -Q 2>&1) # 2>&1 redirects stderr to stdout

stat=$(echo $cmus | grep status | cut -d' ' -f2)

if [ ! -z "$1" ]; then
if [ "$1" == "previous" ]; then
exec cmus-remote -r
elif [ "$1" == "next" ]; then
exec cmus-remote -n
fi

# Ne mogu da provalim zasto ne radi


exec pkill -RTMIN+12 i3blocks
exit
fi

artist=$(cmus-remote -Q | grep "tag\sartist" | sed "s/tag\sartist\s//")


title=$(cmus-remote -Q | grep "title" | sed "s/tag\stitle\s//")

if [ ! -z "$(cmus-remote -Q | grep 'stream')" ]; then


text="$title"
elif [ "$stat" != "stoped" ] && [ "$stat" != "paused" ]; then
text="$artist - $title"
else
text=""
fi

echo "$text"

You might also like