#!/bin/sh

# Define pydm environment
# Source the python enviroment and dependencies
if [ -d /afs/slac/g/lcls ]; then
    source /afs/slac/g/lcls/package/pydm/setup_pydm_env.bash
else
    source /usr/local/lcls/tools/script/go_python2.7.13-x86_64.bash || source /usr/local/lcls/tools/script/go_python2.7.13.bash  
fi

# Get current user
WHO=$(whoami)

# Set variable to the path name for xdg_runtime_dir
FILE='/tmp/bsa-tree-'$WHO

# Make the directory that is needed. if it exits no error
mkdir -p $FILE

# Needs to have 700 permission
chmod 700 $FILE

# Set enviroment variable
export XDG_RUNTIME_DIR=$FILE

python $TOOLS/script/bsa_tree_gui.py -m "$@"
