From 9d44898fb3c2dbac189f5fa7b9b1d789937f348c Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado <55825613+luevano@users.noreply.github.com> Date: Fri, 25 Dec 2020 21:52:30 -0700 Subject: Better "now playing" module --- .local/bin/pctl_status | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 .local/bin/pctl_status (limited to '.local/bin/pctl_status') diff --git a/.local/bin/pctl_status b/.local/bin/pctl_status new file mode 100755 index 0000000..0eccfb8 --- /dev/null +++ b/.local/bin/pctl_status @@ -0,0 +1,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 -- cgit v1.2.3-70-g09d2