summaryrefslogtreecommitdiff
path: root/.local/bin/statusbar/player_mpris_zscroll_module
blob: 593018261f09a336ff89d85d0b399114b11bdb0e (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh

# This is a static status module, for a dynamic one, there is the option
# with zscroll.

icon=" "
length=50
delay=0.1
b_padding=$icon
a_padding=""
p_padding="  |  "

show_panel (){
	zscroll -d $delay -l $length \
		-M "pctl_status status" \
		-m "Playing" "--scroll-padding '$p_padding' --scroll 1" \
		-m "Paused" "--scroll 0" \
		-m "Stopped" "--scroll 0" \
		-m "NRP" "--scroll 0" \
		-u true "pctl_status text" &

	wait
}

send_notification (){
	player_status=$(playerctl status 2> /dev/null)
	if [ "$player_status" = "Playing" ]; then
		artist="$(playerctl metadata artist)"
		album="$(playerctl metadata album)"
		title="$(playerctl metadata title)"

		if [ $album = "\n"]; then
			notify-send "$icon $artist - $album" "$title"
		else
			notify-send "$icon $artist" "$title"
		fi
	elif [ "$player_status" = "Paused" ]; then
		artist="$(playerctl metadata artist)"
		album="$(playerctl metadata album)"
		title="$(playerctl metadata title)"

		if [ $album = "\n"]; then
			notify-send "$icon (Paused) $artist - $album" "$title"
		else
			notify-send "$icon (Paused) $artist" "$title"
		fi
	else
		notify-send "$icon Nothing playing"
	fi

}

case $1 in
	show)
		show_panel
		;;
	notify)
		send_notification
		;;
esac