# Little help needed with tint2 pyradio panel info

**URL:** https://forum.maboxlinux.org/t/little-help-needed-with-tint2-pyradio-panel-info/1390
**Category:** Tint2 Panels
**Created:** [June 10, 2023, 8:59am UTC](https://forum.maboxlinux.org/t/little-help-needed-with-tint2-pyradio-panel-info/1390 "2023-06-10T08:59:06Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![muzqs](https://forum.maboxlinux.org/user_avatar/forum.maboxlinux.org/muzqs/32/3702_2.png) [@muzqs](https://forum.maboxlinux.org/u/muzqs)
#### Post date: [June 10, 2023, 8:59am UTC](https://forum.maboxlinux.org/t/little-help-needed-with-tint2-pyradio-panel-info/1390/1 "2023-06-10T08:59:06Z")

</div>

**Anybody** … A little help needed with tint2` pyradio-panel-info.sh`

I made a little script that shows the Artist and title of Pyradio in tint2.  
**It works.**

Only if there is a …

> &

… character in the Title, **there is no output**.

How can I adjust the **`&`** issue. 🙂

```auto
#!/bin/sh

readonly STR="$(awk '// { save=$0 }END{ print save }' ~/.config/pyradio/pyradio-titles.log)"

function PID_ON {
	pidof -x pyradio
}

# Show Pyradio title in tint2

if PID_ON
then
	echo "${STR:21:100}"
fi

if ! PID_ON 
then
	echo ""
fi

```

![Mabox_20230610-10-53-41](https://forum.maboxlinux.org/uploads/default/original/2X/c/ce72a33367ddfad3d9149916e5f0c312c2e9a23f.png)

🐦

---

<div class="post-metadata">

### Author: ![muzqs](https://forum.maboxlinux.org/user_avatar/forum.maboxlinux.org/muzqs/32/3702_2.png) [@muzqs](https://forum.maboxlinux.org/u/muzqs)
#### Post date: [June 10, 2023, 9:05am UTC](https://forum.maboxlinux.org/t/little-help-needed-with-tint2-pyradio-panel-info/1390/2 "2023-06-10T09:05:55Z")

</div>

> [@muzqs](#):
>
> `echo "${STR:21:100}"`

Note if anyone wants to use it.

Change **`:100`** to shorten the sentence, should it be too long for the panel.

### Edit:wrong info

still learning 🙂

---

<div class="post-metadata">

### Author: ![napcok](https://forum.maboxlinux.org/user_avatar/forum.maboxlinux.org/napcok/32/410_2.png) [@napcok](https://forum.maboxlinux.org/u/napcok)
#### Post date: [June 10, 2023, 9:34am UTC](https://forum.maboxlinux.org/t/little-help-needed-with-tint2-pyradio-panel-info/1390/3 "2023-06-10T09:34:01Z")

</div>

`&` is a special character.  
You need to find a way to replace it. In case of tint2 executor probably `&amp;` could work.

---

<div class="post-metadata">

### Author: ![napcok](https://forum.maboxlinux.org/user_avatar/forum.maboxlinux.org/napcok/32/410_2.png) [@napcok](https://forum.maboxlinux.org/u/napcok)
#### Post date: [June 10, 2023, 10:05am UTC](https://forum.maboxlinux.org/t/little-help-needed-with-tint2-pyradio-panel-info/1390/4 "2023-06-10T10:05:49Z")

</div>

With Bash it will be easier and faster 🙂

```auto
#!/bin/bash
shopt -s extglob

if pidof -x pyradio &>/dev/null;then
	TITLE=$(tail -n 1 ~/.config/pyradio/pyradio-titles.log|cut -d'|' -f2)
	TITLE=${TITLE##*( )} # remove leading spaces
	echo "${TITLE/&/&amp;}" # replace 
else
	echo ""
fi

```

---

<div class="post-metadata">

### Author: ![muzqs](https://forum.maboxlinux.org/user_avatar/forum.maboxlinux.org/muzqs/32/3702_2.png) [@muzqs](https://forum.maboxlinux.org/u/muzqs)
#### Post date: [June 10, 2023, 11:10am UTC](https://forum.maboxlinux.org/t/little-help-needed-with-tint2-pyradio-panel-info/1390/5 "2023-06-10T11:10:06Z")

</div>

> [@napcok](#):
>
> With Bash

**Thanks for the lines … 🐧**  
Don’t know why i used sh. I mainly use bash.

> [@napcok](#):
>
> `shopt -s extglob`

_-s = enable (set) each OPTNAME_  
_Exit Status:_  
_Returns success if OPTNAME is enabled; fails if an invalid option is_  
_given or OPTNAME is disabled._

**Can you please explain what is happening here.**  
`Shopt` = checks enabled / disabled extglob.  
`Extglob` = mystery

🐦

---

<div class="post-metadata">

### Author: ![napcok](https://forum.maboxlinux.org/user_avatar/forum.maboxlinux.org/napcok/32/410_2.png) [@napcok](https://forum.maboxlinux.org/u/napcok)
#### Post date: [June 10, 2023, 11:13am UTC](https://forum.maboxlinux.org/t/little-help-needed-with-tint2-pyradio-panel-info/1390/6 "2023-06-10T11:13:30Z")

</div>

> [@napcok](#):
>
> shopt -s extglob

Here it is required for removing leading spaces (without need to use external tools like sed for example).

[https://thequickadvisor.com/what-does-the-shopt-command-do-in-linux/](https://thequickadvisor.com/what-does-the-shopt-command-do-in-linux/)

> **[Bash Quick Start Guide](https://www.oreilly.com/library/view/bash-quick-start/9781789538830/2609b05c-60fa-443d-bb5f-d5cd7626374f.xhtml)**
>
> Extended globbing Creative use of globbing syntax can do a great deal of advanced pattern matching, but in some cases we may need something more advanced, perhaps approaching... - Selection from Bash Quick Start Guide \[Book\]

---

<div class="post-metadata">

### Author: ![muzqs](https://forum.maboxlinux.org/user_avatar/forum.maboxlinux.org/muzqs/32/3702_2.png) [@muzqs](https://forum.maboxlinux.org/u/muzqs)
#### Post date: [June 14, 2023, 11:39am UTC](https://forum.maboxlinux.org/t/little-help-needed-with-tint2-pyradio-panel-info/1390/7 "2023-06-14T11:39:20Z")

</div>

Now that Pyradio server is working stable 🙂 , I modified the script of Pyradio panel title.  
It checks **Playback/Idle** status through the server.

##### Operation :

```auto
Server ON : Title is displayed at PLAYBACK. Title disappears in PAUSE mode.
Server OFF : Title is always displayed.

```

#### Remark :

It can happen that the title does not appear, but everything is ok, then there is a `&` in the title somewhere in the way to display the text.  
Check ~/.config/pyradio/pyradio-titles.log to see the `&` in the title.  
It’s already a lot less with @napcok’s adjustments.

```auto
#!/bin/bash
shopt -s extglob

pyradio_status="$(curl http://127.0.0.1:9998/html/info | grep 'Status' | grep playback | wc -l)"

if test $pyradio_status -gt 0 
 then
	TITLE=$(tail -n 1 ~/.config/pyradio/pyradio-titles.log|cut -d'|' -f2)
	TITLE=${TITLE##*( )} # remove leading spaces
	echo "${TITLE/&/&amp;}" # replace 
else
	echo ""
fi

```

Idle

 ![Mabox_20230614-13-06-09](https://forum.maboxlinux.org/uploads/default/original/2X/7/72a071b6a8ab6ad5171e8c080fca0439fa77a8cf.png)

Playback

 ![Mabox_20230614-13-06-39](https://forum.maboxlinux.org/uploads/default/original/2X/1/1978618b7dc6eac024dec8b65920e5385367f4e7.png)
