ebruck / radiotray-ng

An Internet radio player for Linux
GNU General Public License v3.0
255 stars 23 forks source link

A method to trigger notification #178

Closed apitanga closed 2 years ago

apitanga commented 2 years ago

I'm trying to figure out a method to wrap a keyboard shortcut around to display (send notification of) the currently playing Station, Artist and Title, not unlike how radiotray-ng already does normally when that information changes, but upon request.

I could not find a dbus method or a CLI flag to just show/notify the currently playing information. Is there a simple way that I may be missing, or is this a fair request for new feature?

ebruck commented 2 years ago

Have a look at the README.md

ebruck commented 2 years ago

Using the helper script rtng-dbus you can do something like this:

rtng-dbus get_player_state |  jq .title,.artist | xargs notify-send -i radiotray-ng-notification
apitanga commented 2 years ago

Thank you, I'll check it out

apitanga commented 2 years ago

Ended up going with,


artist_title=$(rtng-dbus get_player_state | jq '.artist,.title | select( . != null )' | tr -d '"' | tr -d
'\\')
station=$(rtng-dbus get_player_state | jq '.station' | tr -d '"' | tr -d '\\')
notify-send -i radiotray-ng-notification "$station" "$artist_title"