RaySession
RaySession copied to clipboard
env variables exported ?
What are the env variables exported before calling each applicaitons in a ray session ? ( SESSION_NAME, SESSION_ROOT ...)
Hi ! A client will just have NSM_URL. ray-proxy (which is a client) will set for its process NSM_CLIENT_ID, RAY_SESSION_NAME and CONFIG_FILE, a different PWD and unset NSM_URL.
Saying that, it's quite strange to have NSM_CLIENT_ID and RAY_SESSION_NAME, maybe I should copy theses var to RAY_CLIENT_ID and NSM_SESSION_NAME too.
for specific usecases (and only with git master version for now), you have access to many many things with the CLI ray_control.
Can I know for which reason are you asking this ?
I'm currently programming a wizard that creates Ray sessions for different needs.
One of my use case is to stream audio using obs, icecast2 and jamulus.
In the wizard configuration, i ask for various informations which i check and then dispatch in raysession.xml and patch.xml. I have seen that there is a template mechanism but don't know if it can help.
By now, i put variables in xml files such as xxx-my_variable-xxx and some program replace these strings with the needed values. It's my way of templating Ray session. But i would be happy if there is a ray session way.
In my use case, I have to start scripts along with the ray session that need to know the RAY_SESSION_ROOT and the RAY_SESSION_NAME in order to do various initialization. I put configuration files in the ray session name dir.
I would like the Ray sessions created with the wizard to be portable to another machine which runs the same software.
heyhey, really interesting. It's a curious coincidence. I just terminate the option "Sessions scripts". you will see in source code root a dir named "session scripts", it contains some possible session scripts.
Session is scripted with a dir named 'ray-scripts' in the session dir or in a parent dir. For example, the session "/home/user/Ray Sessions/my session" will execute scripts in "/home/user/Ray Sessions/my session/ray-scripts" or in "/home/user/Ray Sessions/ray-scripts" or even "/home/user/ray-scripts".
Recognized scripts in 'ray-scripts' dir can be: load.sh, save.sh and close.sh. Theses scripts will be executed each time a session is respectively loaded, saved or closed. Take a look to "session scripts/base scripts" dir in RaySession source code to see how it can works and which env variables are set for theses scripts.
type ray_control --help to see all datas you can access easily.
Don't hesitate to ask if you need other environmental variables, more datas from ray_control or more explanation.
The most important session script I have already written is save_jack_config. It saves jack configuration and load it when you load the session. At session close (if user is not switching to another session managed by the script), it reloads previous jack configuration. Note that this script works fine for me, but has not been tested by any other. I terminate it yesterday !
Very interesting, i will try the save/restore jack configuration.
I don't know if i need proxy client. I use the classic client and i can do nearly all my processing using this type. At this time, i find the classic client to be more intuitive.
I added a env variable RAY_SESSION_ROOT in ~/.profile with this variable i can access to XDG_CONFIG_HOME=$RAY_SESSION_ROOT/$RAY_SESSION_NAME/config as the raysession name is known at the generation time. But this way, the raysession name can no longer be changed without breaking the raysession ...
What i would need for each application is :
- PWD set to $RAY_SESSION_ROOT/$RAY_SESSION_NAME
- RAY_SESSION_ROOT
- RAY_SESSION_NAME env variables set.
Sorry, maybe I misspoke. I won't add any environment variables for clients. Clients should be NSM compatible and follow the OSC protocol, else it simply should behave as if they were launched from terminal. I don't want to allow development of clients compatible only with RaySession.
What I said is: probably what you are writing should be launched via session scripts and not as client, and in session scripts you can easily access to some env vars or via ray_control.
for example: you've got RAY_SESSION_PATH which is the session's folder
to get session root: session_root=$(ray_control get_root)
to get session name: session_name=$(ray_control get_session_name)
Important note: session_path is not necessarily session_root/session_name for many reasons. 1, session can be in a subfolder, and session_name doesn't contains any '/', 2, it's possible to load a session that is not in session_root.
Thank you very much for these detailed informations. It will help me. I will create the raysession.xml during the session load using ray-scripts.
I ve cloned the ray gît repository and try to figure out how to use the jack scripted session. I will post an issue with detailed informations (error message...)
To be more precise, I think you should 1 ) make your session with the needed clients and the needed load script (maybe save and close could be useful too, it depends of what you want to do). You should not write the raysession.xml file directly, it's better to let ray-daemon do that for backward compatibility reasons, and I really don't see why you would need to do this. 2 ) when your happy with your session and consider it is a good template, you copy this to your wizard source code 3 ) In the wizard, here are some tweaks that could be useful
If you wants to set this session as template: first you have to copy this session to a writable path, ray-daemon won't accept to load an unwritable directory, then:
ray_control open_session_off my_session_path
ray_control set_as_template my_session_template
ray_control close
Note that open_session_off means "open the session" but without launching any client. It allows to read and modify some client and session properties quickly, without have to modify himself raysession.xml .
then if you want to add a new session with this template
ray_control new_session my_new_session my_session_template
Thanks for your help !
I translated my template mechanism to use ray_control instead of xml and that works fine but i'm still creating an xml file for jack connexions. Is there a programmatic way to create jack connexions within a session for use with ray-jackpatch or other jack connexion management ?
Indeed, there is no mechanism to modify the ray-jackpatch file. But I don't understand why you need to write this file and not just copy a complete existing file. Alternatively, you also can use the commands jack_connect and jack_disconnect, theses commands come with jackd2 package on my distrib.
The template mechanism i use depends on variables and flow control. There is not always the same client parameters nor always the same Jack connections in the Raysession document.
a simple example would be an application with a specific jack client name:
myapp --clientname "myapp Laurent"
would be in a template: myapp --jack-client-name "myapp $username"
One client is created for each user : it has parameterized command line ($username) and jack inputs/outputs are different:
myapp $username:in_1 and myapp $username:out_1
I don't know if RaySession template mechanism can handle such situation.
Ok. I see different ways to workaround this (I am not sure, you'll know it better than me, these are just some ideas).
- proxy launching a script: proxy client could start a script in proxy directory. for example, the proxy dir can contains a script named "my_script", this script could be like this :
#!/bin/bash
# write something to get some data...
username=$(cat a_file_containing_vars_i_need|grep what_i_need)
exec myapp --jack-client-name "myapp $username" "$@"
set executable (in proxy properties) to:
./my_script
Obviously for username it's not needed, because you've got it with $USER env variable. Just put $USER in the proxy arguments and it should works ;)
- Use session scripts to connect directly the good JACK connections once the session is loaded. in load.sh session script, after ray_control run_step (which loads the session), you can write something as:
jack_connect $username:out_1 system:playback_1
jack_connect $username:out_2 system:playback_2
same thing, you can store the needed vars in a file in the session dir and get values from the script. Obviously for username it's not needed, because you've got it with $USER env variable.