tizonia-openmax-il icon indicating copy to clipboard operation
tizonia-openmax-il copied to clipboard

Ideas on how to control remotely via ssh?

Open jpcaldwell30 opened this issue 4 years ago • 8 comments

I have solved all my issues running the app however i am trying to figure out how to control the app remotely via ssh. I have tizonia running on my headless raspberry pi inside a docker container which is connected to my speakers and i would like to be able to control it (mute, volume +/-, next track[n], previous [p]) by sending ssh commands. Does anyone have any idea on how this might be possible? I looked at xdotool and similar tools but i don't think this will work in this situation since i am running the pi headless with the desktop disabled. I am hoping to be able to use tasker on my phone to send ssh commands in a tasker shortcut i made to effectively turn my phone into a remote.

jpcaldwell30 avatar Dec 21 '19 02:12 jpcaldwell30

Hi! @jpcaldwell30

Thanks for checking out the software. That sounds really cool. Have you published anywhere the steps to reproduce your setup?. I think I may have some time alone with a new Rpi4 this coming holiday, so I might be able to give it a go.

In the meantime, and for ideas, Tizonia supports MPRISv2 (although admittedly, in a buggy way).

You need to enable the interface in the config file:

# MPRIS v2 interface enable/disable switch
# -------------------------------------------------------------------------
# Valid values are: true | false
#
mpris-enabled = true

After that, you can use tizonia-remote, like in these aliases:

alias play='tizonia-remote play'
alias next='tizonia-remote next'
alias prev='tizonia-remote prev'
alias pause='tizonia-remote pause'
alias stop='tizonia-remote stop'
alias quit='tizonia-remote quit'
alias vol='tizonia-remote volume'
alias n='next'
alias p='prev'
alias m='pause'
alias q='quit'

This should allow you to interact via ssh with Tizonia with the application running natively. The challenge would be to extend this to the containerized solution.

tizonia avatar Dec 21 '19 09:12 tizonia

Sorry, I keep forgetting that tizonia-remote is not distributed in the Debian packages (although in my todo list for a long time!)

The script is in the repo, in this location: https://github.com/tizonia/tizonia-openmax-il/blob/master/player/tools/tizonia-remote.in

Or you can download it from here: tizonia-remote.zip

tizonia avatar Dec 21 '19 09:12 tizonia

Some more info: this is the solution that I use to have D-Bus in a headless Rpi: https://pastebin.com/6jSTHQ2M

tizonia avatar Dec 21 '19 09:12 tizonia

Thank you so much for this! I will publish something on the whole process once i get it up and running for sure. Unfortunately at the moment i have run into some more problems. Every time i try and run the tizonia-remote script i get two error messages: Failed to open connection to "session" message bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11 D-Bus per-session daemon address is: unix:abstract=/tmp/dbus-d3SXb7sxOg,guid=e04097ec2770c32c194daa975dfeee18 D-Bus per-session daemon PID is : 41 "--dest=" requires an NAME Usage: dbus-send [--help] [--system | --session | --bus=ADDRESS | --peer=ADDRESS] [--dest=NAME] [--type=TYPE] [--print-reply[=literal]] [--reply-timeout=MSEC] [contents ... As far as i know this doesn't have anything to do with it running in a docker container. I was planning on figuring out how to get the commands into docker later anyway. The issue seems to be with the environment variables since the setup is headless. It keeps complaining about X11. I did some troubleshooting and found that if i ran "eval dbus-launch --autolaunch" first in the shell before running tizonia-remote, i could get the fist message to go away. Further troubleshooting showed that If i run this command from the script 'dbus-send --session
--dest=org.freedesktop.DBus
--type=method_call
--print-reply
/org/freedesktop/DBus
org.freedesktop.DBus.ListNames ' by itself after running eval dbus-launch --autolaunch it does not produce the first error but wont return anything with the name "tizonia" so i think the second error is caused by the script failing to find anything with the name tizonia from that command. I also tried running your dbus init script before running tizonia but still ran into issues. For some reason it seemed like the dbus init script wan not outputting anything into the dbus_vars file. Any ideas? Thank you so much for your help by the way.

jpcaldwell30 avatar Dec 22 '19 04:12 jpcaldwell30

I've been using tizonia for a few months on a headless RPi using iOS Shortcuts to execute a custom Bash script via SSH. I use tmux to open a "headless" terminal session and then run tizonia in it. tmux allows you to send commands directly to a specified tmux session, so it's really flexible. I'm sure this can be done in screen a number of other multiplexers, I just have the most experience with tmux. See one of my basic functions below, I'm only using it for next/previous control because that's all I currently need, but with the case statement I can easily scale it out to whatever I want tizonia to do.

function plexcontrol()
{
  case $1 in
    "next") if $(tmux has-session -t tizonia-plex); then tmux send-keys -t tizonia-plex n; fi;;
    "previous") if $(tmux has-session -t tizonia-plex); then tmux send-keys -t tizonia-plex p; fi;;
    *)
  esac
}

That being said, I'm excited to learn about tizonia-remote and will be looking into this script to see if it would improve/simplify my workflow.

bmbvenom avatar Dec 28 '19 01:12 bmbvenom

I am trying to control tizonia on a headless Raspberry Pi zero (which includes a Pirate Audio Headphone Amp HAT) via SSH using keyboard shortcuts. All shortcuts work fine except the ones related to the volume: [+/-] [Up/Down] increase/decrease volume. [m] mute. The volume stays invariably to 100%... I tried most of the above tricks, but nothing seems to work as far as the volume control is concerned. Any idea?

Florent-Baty avatar May 25 '20 11:05 Florent-Baty

I haven't tried controlling volume directly via tizonia, but I pass arguments into my custom script I talked about above that then calls a function that uses the ALSA mixer to set a specific volume %, control volume in +/- 10% increments, and toggle mute. I do it this way because it controls the system volume, so it also works with the other players I use (e.g. vlc). The vanilla version of the commands I use are below:

/usr/bin/amixer set PCM <desiredpercentage>%
/usr/bin/amixer set PCM 10%+
/usr/bin/amixer set PCM 10%-
/usr/bin/amixer set PCM toggle

bmbvenom avatar May 26 '20 07:05 bmbvenom

Thanks a lot for your feedback! The ALSA mixer somehow does not seem to communicate properly with the hifiberry-dac included in the HAT. After sending the command /usr/bin/amixer set PCM 50% in tmux, there is no reaction, no volume control (always stays at 100%)...

Florent-Baty avatar May 27 '20 14:05 Florent-Baty