aboutsummaryrefslogtreecommitdiff
path: root/cmusShow.sh
blob: a28d8f2f907fe8b784713d4c08e82085b1c69c7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh

# Shows a notification with info about the current playing song.

getCmusInfo() {
	cmus-remote -Q | grep "^${1} " | cut -d' ' -f "${2}-"
}

sToTime() {
	min=$(( $1 / 60 ))
	s=$(( $1 % 60 ))
	[ "$s" -lt 10 ] && s="0${s}"
	echo "${min}:${s}"
}

artist="$(getCmusInfo 'tag artist' '3')"
album="$(getCmusInfo 'tag album' '3')"
title="$(getCmusInfo 'tag title' '3')"
position="$(getCmusInfo 'position' '2')"
duration="$(getCmusInfo 'duration' '2')"
dunstify -r "$(dunstifyIDs.sh cmusShow)" "${title}" "${artist} - ${album}\n$(sToTime ${position}) - $(sToTime ${duration})"