forked from jupyterhub/jupyter-remote-desktop-proxy
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path__init__.py
54 lines (49 loc) · 1.4 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import os
import shlex
from shutil import which
import tempfile
HERE = os.path.dirname(os.path.abspath(__file__))
def setup_desktop():
# make a secure temporary directory for sockets
# This is only readable, writeable & searchable by our uid
sockets_dir = tempfile.mkdtemp()
sockets_path = os.path.join(sockets_dir, 'vnc-socket')
vncserver = which('vncserver')
if vncserver:
vnc_args = [
vncserver,
]
socket_args = []
else:
# Use bundled tigervnc
vnc_args = [
os.path.join(HERE, 'share/tigervnc/bin/vncserver'),
'-rfbunixpath', sockets_path,
]
socket_args = [
'--unix-target', sockets_path
]
vnc_command = ' '.join(shlex.quote(p) for p in (vnc_args + [
'-verbose',
'-xstartup', os.path.join(HERE, 'share/xstartup'),
'-geometry', '1680x1050',
'-SecurityTypes', 'None',
'-fg',
':1',
]))
return {
'command': [
'websockify', '-v',
'--web', os.path.join(HERE, 'share/web/noVNC-1.2.0'),
'--heartbeat', '30',
'5901',
] + socket_args + [
'--',
'/bin/sh', '-c',
f'cd {os.getcwd()} && {vnc_command}'
],
'port': 5901,
'timeout': 30,
'mappath': {'/': '/vnc_lite.html'},
'new_browser_window': True
}