aboutsummaryrefslogtreecommitdiff
path: root/i3/blocks/cmus
blob: f4d15b30ff2f3e705a92525c5dbbda7bd7a0234b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash

INFO_CMUS=$(cmus-remote -Q 2>/dev/null)
if [[ $? -eq 0 ]]; then
  INFO_TITLE=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*title//p' | head -n 1)
  INFO_ALBUM=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*album//p' | head -n 1)
  INFO_ARTIST=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*artist//p' | head -n 1)
else
  exit
fi

if [[ "${INFO_ARTIST}" ]] && [[ "${INFO_TITLE}" ]]; then
  OUT_TEXT=$(echo "${INFO_ARTIST} - ${INFO_TITLE}" | xargs)
elif [[ "${INFO_TITLE}" ]]; then
  OUT_TEXT=$(echo "${INFO_TITLE}" | xargs)
fi

echo "${OUT_TEXT}"
echo "${OUT_TEXT}"
exit