From 3a025bbf0d9c34a5eceb417f4e853bee49d18996 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Mon, 4 Nov 2024 22:30:04 +0000 Subject: [PATCH] Override xstartup with environment variable Defines the variable `JUPYTER_REMOTE_DESKTOP_PROXY_XSTARTUP` to launch a custom xstartup script --- README.md | 6 ++++++ jupyter_remote_desktop_proxy/setup_websockify.py | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 74e3ec2d..ace7048b 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,12 @@ to start daemons (such as dbus, pulseaudio, etc) necessary for linux desktop to work. This is the option kubernetes runs with by default, so most kubernetes based JupyterHubs will not need any modifications for this to work. +## Configuration + +The VNC server will default to launching `~/.vnc/xstartup`. +If this file does not exist jupyter-remote-desktop-proxy will use a bundled `xstartup` file that launches `dbus-launch xfce4-session`. +You can specify a custom script by setting the environment variable `JUPYTER_REMOTE_DESKTOP_PROXY_XSTARTUP`. + ## Limitations 1. Desktop applications that require access to OpenGL are currently unsupported. diff --git a/jupyter_remote_desktop_proxy/setup_websockify.py b/jupyter_remote_desktop_proxy/setup_websockify.py index e1389694..cbbab0db 100644 --- a/jupyter_remote_desktop_proxy/setup_websockify.py +++ b/jupyter_remote_desktop_proxy/setup_websockify.py @@ -33,8 +33,11 @@ def setup_websockify(): unix_socket = False vnc_args = [vncserver, '-localhost', '-rfbport', '{port}'] - if not os.path.exists(os.path.expanduser('~/.vnc/xstartup')): - vnc_args.extend(['-xstartup', os.path.join(HERE, 'share/xstartup')]) + xstartup = os.getenv("JUPYTER_REMOTE_DESKTOP_PROXY_XSTARTUP") + if not xstartup and not os.path.exists(os.path.expanduser('~/.vnc/xstartup')): + xstartup = os.path.join(HERE, 'share/xstartup') + if xstartup: + vnc_args.extend(['-xstartup', xstartup]) vnc_command = shlex.join( vnc_args