Knowledge Base
Searching in : Article
ID: AR10L00815
Applies to: NoMachine Software
Added on: 2014-10-01
Last Update: 2014-10-01

How to make available custom environment variables inside a NoMachine virtual desktop

In some cases, administrators need to set some specific environment variables inside the NoMachine session.

This can be done by creating a wrapper script to be executed when the user creates a new virtual desktop.

This script must include the environment variables to be set and the command for starting the virtual desktop.

 

1. Check in the node configuration file (/usr/NX/etc/node.cfg) which is the command to start the virtual desktop.

     It's set in the DefaultDesktopCommand key.

     For example on openSUSE 12.1 x86_64: 

     DefaultDesktopCommand "/usr/bin/gnome-session --session=gnome-fallback"

 

2. Create the nxsession.sh script, it can look like:

#!/bin/bash

#
# Set environment variables.
#

export VARIABLE1="value1"

export VARIABLE2="value2"

#
# Execute the command to start the virtual desktop.
#

/usr/bin/gnome-session --session=gnome-fallback

 

2.  Place the nxsession.sh script for example into the /usr/local/bin/ directory.
 

3. Be sure that the nxsession.sh script is executable.
 

4. Finally modify the value of the DefaultDesktopCommand key  in the node.cfg file to point to the script:

     DefaultDesktopCommand "/usr/local/bin/nxsession.sh"

 

This change will be effective when creating a new virtual desktop, there is no need to restart the server.

To verify if the new variables are set in the NoMachine session, open a terminal inside the session and execute the printenv command.

 

Future versions will support the possibility of defining environment variables in a custom script configurable on the node:

https://www.nomachine.com/FR10L02834