~jbauer/dotfiles

ref: daebf07b03e1fe9fe376eb75d5dd061c8fa047d3 dotfiles/.local/bin/tmux-bar -rwxr-xr-x 1.0 KiB
daebf07bJake Bauer Update README 11 months ago
                                                                                
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
#!/bin/sh

nowPlaying=$(cmus-remote -Q 2>/dev/null)
title=$(echo "$nowPlaying" | grep 'tag title' | cut -d' ' -f3-)
artist=$(echo "$nowPlaying" | grep 'tag artist' | cut -d' ' -f3-)
repeat=$(echo "$nowPlaying" | grep 'set repeat ' | cut -d' ' -f3-)
shuffle=$(echo "$nowPlaying" | grep 'set shuffle' | cut -d' ' -f3-)
duration=$(echo "$nowPlaying" | grep 'duration' | cut -d' ' -f2-)
position=$(echo "$nowPlaying" | grep 'position' | cut -d' ' -f2-)
curStatus=$(echo "$nowPlaying" | head -1 | cut -d' ' -f2)

if [ "$curStatus" != "playing" ] && [ "$curStatus" != "paused" ]; then
    printf "Nothing Playing"
    exit 0
fi

((durationMinutes=$duration/60))
((durationSeconds=$duration%60))
((positionMinutes=$position/60))
((positionSeconds=$position%60))

if [ "$shuffle" = "true" ]; then
    icons=" "
fi
if [ "$repeat" = "true" ]; then
    icons="$icons "
fi

printf "\"%s\" by %s — %02d:%02d/%02d:%02d%s" "$title" "$artist" \
    "$positionMinutes" "$positionSeconds" "$durationMinutes" \
    "$durationSeconds" "$icons"