Set CWD of desktop environment to CWD of notebook

Otherwise it'll be cwd of webroot, which is confusing as
soon as you open a terminal
This commit is contained in:
YuviPanda 2019-11-19 11:06:53 -08:00
parent 3ee7d7eb1d
commit 360f9b04c5
1 changed files with 14 additions and 8 deletions

View File

@ -1,4 +1,5 @@
import os import os
import shlex
import tempfile import tempfile
@ -9,14 +10,8 @@ def setup_desktop():
# This is only readable, writeable & searchable by our uid # This is only readable, writeable & searchable by our uid
sockets_dir = tempfile.mkdtemp() sockets_dir = tempfile.mkdtemp()
sockets_path = os.path.join(sockets_dir, 'vnc-socket') sockets_path = os.path.join(sockets_dir, 'vnc-socket')
return {
'command': [ vnc_command = ' '.join((shlex.quote(p) for p in [
'websockify', '-v',
'--web', os.path.join(HERE, 'share/web/noVNC-1.1.0'),
'--heartbeat', '30',
'5901',
'--unix-target', sockets_path,
'--',
os.path.join(HERE, 'share/tigervnc/bin/vncserver'), os.path.join(HERE, 'share/tigervnc/bin/vncserver'),
'-verbose', '-verbose',
'-xstartup', os.path.join(HERE, 'share/xstartup'), '-xstartup', os.path.join(HERE, 'share/xstartup'),
@ -25,6 +20,17 @@ def setup_desktop():
'-rfbunixpath', sockets_path, '-rfbunixpath', sockets_path,
'-fg', '-fg',
':1', ':1',
]))
return {
'command': [
'websockify', '-v',
'--web', os.path.join(HERE, 'share/web/noVNC-1.1.0'),
'--heartbeat', '30',
'5901',
'--unix-target', sockets_path,
'--',
'/bin/sh', '-c',
f'cd {os.getcwd()} && {vnc_command}'
], ],
'port': 5901, 'port': 5901,
'timeout': 30, 'timeout': 30,