aboutsummaryrefslogtreecommitdiff
path: root/linux/home/.config/polybar/scripts/cmus.sh
blob: 2f42c63594a370d27296e161c03e14d3c34ce23a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash

prepend_zero () {
        seq -f "%02g" $1 $1
}

artist=$(echo -n $(cmus-remote -C status | grep "tag artist" | cut -c 12-))

if [[ $artist = *[!\ ]* ]]; then
        song=$(echo -n $(cmus-remote -C status | grep title | cut -c 11-))
        position=$(cmus-remote -C status | grep position | cut -c 10-)
        minutes1=$(prepend_zero $(($position / 60)))
        seconds1=$(prepend_zero $(($position % 60)))
        duration=$(cmus-remote -C status | grep duration | cut -c 10-)
        minutes2=$(prepend_zero $(($duration / 60)))
        seconds2=$(prepend_zero $(($duration % 60)))
        echo -n "$artist - $song "
else
        echo
fi

#prepend_zero () {
#        seq -f "%02g" $1 $1
#}
#
#artist=$(echo -n $(cmus-remote -C status | grep "tag artist" | cut -c 12-))
#
#if [[ $artist = *[!\ ]* ]]; then
#        song=$(echo -n $(cmus-remote -C status | grep title | cut -c 11-))
#        position=$(cmus-remote -C status | grep position | cut -c 10-)
#        minutes1=$(prepend_zero $(($position / 60)))
#        seconds1=$(prepend_zero $(($position % 60)))
#        duration=$(cmus-remote -C status | grep duration | cut -c 10-)
#        minutes2=$(prepend_zero $(($duration / 60)))
#        seconds2=$(prepend_zero $(($duration % 60)))
#        echo -n "$artist - $song [$minutes1:$seconds1/$minutes2:$seconds2]"
#else
#        echo
#fi