Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Confusing Returns From Radiotray Status Script #208

Open
LinuxMint20 opened this issue Sep 15, 2023 · 0 comments
Open

Multiple Confusing Returns From Radiotray Status Script #208

LinuxMint20 opened this issue Sep 15, 2023 · 0 comments

Comments

@LinuxMint20
Copy link

LinuxMint20 commented Sep 15, 2023

Bear with me, Im not much of a programmer. I have been writing a script, fine tuning it through a mountain of trial and error, and I remain confused as to how to code it to get the right returns in the command line when running the script. It is supposed to return the status of my radiotray app, whther its running, playing, or not running.

Here is the code.

#!/bin/bash

now=$( date "+%a, %e %b, %H:%M:%S" )

app="radiotray-ng"

procbin="application.process.binary"

appid=$( ps -aux | grep -i "$app" | awk '{print $2}' )

playing=$(pacmd list-sink-inputs | grep "$procbin" | grep "$app" | cut -d '"' -f2)

$playing

if [[ $playing = $app ]]; then 
    echo "$now RadioTray Is Playing"
else 
    echo "$now Playing RadioTray"
    /$HOME/.config/radiotray-ng/rtng-dbus play
fi
if  ps -p $appid > /dev/null; then
    echo "$now RadioTray Is Running, pid $appid"
    echo "Not starting another instance."
else
echo "$now RadioTray Is Launching"
    /usr/bin/radiotray-ng --play
    /$HOME/.config/radiotray-ng/rtng-dbus play
fi
exit

This is what I get when it's playing:

An instance of radiotray-ng is already running, pid: 62507 Fri, 15 Sep, 01:20:30 RadioTray Is Playing Fri, 15 Sep, 01:20:30 RadioTray Is Running, pid 62507 66413 Not starting another instance.

Not playing but still running (launched):

Fri, 15 Sep, 01:20:45 Playing RadioTray Fri, 15 Sep, 01:20:45 RadioTray Is Running, pid 62507 66440 Not starting another instance.

And not running at all: Fri, 15 Sep, 01:21:00 Playing RadioTray Error org.freedesktop.DBus.Error.ServiceUnknown: The name com.github.radiotray_ng was not provided by any .service files Fri, 15 Sep, 01:21:00 RadioTray Is Launching

Where it hangs until I exit the app, then returns this: Error org.freedesktop.DBus.Error.ServiceUnknown: The name com.github.radiotray_ng was not provided by any .service files

I would like it to return the status of the player (not running, running but not playing, or playing), and exit cleanly. Every time, if at all possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant