summaryrefslogtreecommitdiff
path: root/.local/bin/pctl_status
blob: 0eccfb8bb887f08713a4a5a8bb2c4cf40041e4cd (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
#!/bin/bash

playerctl_status=$(playerctl status 2>/dev/null)
exit_code=$?

if [ $exit_code -eq 0 ]; then
	status=$playerctl_status
else
	status="NPF"
fi

case $1 in
	status)
		echo "$status"
		;;
	text)
		artist="$(playerctl metadata artist 2>/dev/null)"
		title="$(playerctl metadata title 2>/dev/null)"

		if [ "$status" = "Stopped" ]; then
			echo "%{F$(xresource color8)}No music playing%{F}"
		elif [ "$status" = "Paused" ]; then
			echo "%{F$(xresource color8)}$artist - $title%{F}"
		elif [ "$status" = "NPF" ]; then
			echo "%{F$(xresource color8)}No player found%{F}"
		else
			echo "$artist - $title"
		fi
		;;
esac