From c49a69e6ac7c4da458101fa544ea2431fa134558 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado <55825613+luevano@users.noreply.github.com> Date: Tue, 29 Dec 2020 17:15:50 -0700 Subject: Fix bugs --- .local/bin/pctl_status | 110 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 95 insertions(+), 15 deletions(-) (limited to '.local/bin/pctl_status') diff --git a/.local/bin/pctl_status b/.local/bin/pctl_status index 0eccfb8..bc6af6e 100755 --- a/.local/bin/pctl_status +++ b/.local/bin/pctl_status @@ -1,30 +1,110 @@ -#!/bin/bash +#!/bin/sh -playerctl_status=$(playerctl status 2>/dev/null) -exit_code=$? +get_pctl_status () { + player="$(check_for_mpd)" -if [ $exit_code -eq 0 ]; then - status=$playerctl_status -else - status="NPF" -fi + if [ "$player" = "" ]; then + playerctl_status=$(playerctl status 2>/dev/null) + else + playerctl_status=$(playerctl -p "$player" status 2>/dev/null) + fi + exit_code=$? -case $1 in - status) - echo "$status" - ;; - text) - artist="$(playerctl metadata artist 2>/dev/null)" - title="$(playerctl metadata title 2>/dev/null)" + if [ $exit_code -eq 0 ]; then + echo "$playerctl_status" + else + echo "NPF" + fi +} + +check_for_mpd () { + pctl_players="$(playerctl -l)" + + while IFS= read line; do + line="$(echo $line | sed -e 's/\ //')" + + if [ "$line" = "mpd" ]; then + echo "$line" + fi + done <$artist>$album>$title" + fi + else + if [ "$status" = "Playing" ] || [ "$status" = "Paused" ]; then + artist="$(playerctl metadata artist)" + album="$(playerctl metadata album)" + title="$(playerctl metadata title)" + + if [ "$album" = "" ]; then + echo "no>$artist>$title" + else + echo "yes>$artist>$album>$title" + fi + fi + fi +} + +case $1 in + status) + get_pctl_status + ;; + text) + get_display_text + ;; + get-metadata) + get_metadata ;; esac -- cgit v1.2.3-70-g09d2