Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit 105e206

Browse files
author
CI
committed
Automated update for script library changes
1 parent d03324d commit 105e206

File tree

1 file changed

+89
-59
lines changed

1 file changed

+89
-59
lines changed

repository-containers/images/github.com/microsoft/vscode/.devcontainer/library-scripts/desktop-lite-debian.sh

Lines changed: 89 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/desktop-lite.md
88
# Maintainer: The VS Code and Codespaces Teams
99
#
10-
# Syntax: ./desktop-lite-debian.sh [non-root user] [vnc password] [install no vnc flag]
10+
# Syntax: ./desktop-lite-debian.sh [non-root user] [Desktop password] [Install web client flag] [VNC port] [Web Port]
1111

1212
USERNAME=${1:-"automatic"}
1313
VNC_PASSWORD=${2:-"vscode"}
1414
INSTALL_NOVNC=${3:-"true"}
15+
VNC_PORT="${4:-5901}"
16+
NOVNC_PORT="${5:-6080}"
1517

1618
NOVNC_VERSION=1.2.0
1719
WEBSOCKETIFY_VERSION=0.10.0
@@ -77,6 +79,71 @@ if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
7779
elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
7880
USERNAME=root
7981
fi
82+
# Add default Fluxbox config files if none are already present
83+
fluxbox_apps="$(cat \
84+
<< 'EOF'
85+
[transient] (role=GtkFileChooserDialog)
86+
[Dimensions] {70% 70%}
87+
[Position] (CENTER) {0 0}
88+
[end]
89+
EOF
90+
)"
91+
92+
fluxbox_init="$(cat \
93+
<< 'EOF'
94+
session.configVersion: 13
95+
session.menuFile: ~/.fluxbox/menu
96+
session.keyFile: ~/.fluxbox/keys
97+
session.styleFile: /usr/share/fluxbox/styles/qnx-photon
98+
session.screen0.workspaces: 1
99+
session.screen0.workspacewarping: false
100+
session.screen0.toolbar.widthPercent: 100
101+
session.screen0.strftimeFormat: %a %l:%M %p
102+
session.screen0.toolbar.tools: RootMenu, clock, iconbar, systemtray
103+
session.screen0.workspaceNames: One,
104+
EOF
105+
)"
106+
107+
fluxbox_menu="$(cat \
108+
<< 'EOF'
109+
[begin] ( Application Menu )
110+
[exec] (File Manager) { nautilus ~ } <>
111+
[exec] (Text Editor) { mousepad } <>
112+
[exec] (Terminal) { tilix -w ~ -e $(readlink -f /proc/$$/exe) -il } <>
113+
[exec] (Web Browser) { x-www-browser --disable-dev-shm-usage } <>
114+
[submenu] (System) {}
115+
[exec] (Set Resolution) { tilix -t "Set Resolution" -e bash /usr/local/bin/set-resolution } <>
116+
[exec] (Edit Application Menu) { mousepad ~/.fluxbox/menu } <>
117+
[exec] (Passwords and Keys) { seahorse } <>
118+
[exec] (Top Processes) { tilix -t "Top" -e htop } <>
119+
[exec] (Disk Utilization) { tilix -t "Disk Utilization" -e ncdu / } <>
120+
[exec] (Editres) {editres} <>
121+
[exec] (Xfontsel) {xfontsel} <>
122+
[exec] (Xkill) {xkill} <>
123+
[exec] (Xrefresh) {xrefresh} <>
124+
[end]
125+
[config] (Configuration)
126+
[workspaces] (Workspaces)
127+
[end]
128+
EOF
129+
)"
130+
131+
# Copy config files if the don't already exist
132+
copy_fluxbox_config() {
133+
local target_dir="$1"
134+
mkdir -p "${target_dir}/.fluxbox"
135+
touch "${target_dir}/.Xmodmap"
136+
if [ ! -e "${target_dir}/.fluxbox/apps" ]; then
137+
echo "${fluxbox_apps}" > "${target_dir}/.fluxbox/apps"
138+
fi
139+
if [ ! -e "${target_dir}/.fluxbox/init" ]; then
140+
echo "${fluxbox_init}" > "${target_dir}/.fluxbox/init"
141+
fi
142+
if [ ! -e "${target_dir}/.fluxbox/menu" ]; then
143+
echo "${fluxbox_menu}" > "${target_dir}/.fluxbox/menu"
144+
fi
145+
}
146+
80147

81148
# Function to run apt-get if needed
82149
apt_get_update_if_needed()
@@ -163,11 +230,10 @@ if [ "${INSTALL_NOVNC}" = "true" ] && [ ! -d "/usr/local/novnc" ]; then
163230
fi
164231

165232
# Set up folders for scripts and init files
166-
mkdir -p /var/run/dbus /usr/local/etc/vscode-dev-containers/ /root/.fluxbox
233+
mkdir -p /var/run/dbus /usr/local/etc/vscode-dev-containers/
167234

168235
# Script to change resolution of desktop
169-
tee /usr/local/bin/set-resolution > /dev/null \
170-
<< EOF
236+
cat << EOF > /usr/local/bin/set-resolution
171237
#!/bin/bash
172238
RESOLUTION=\${1:-\${VNC_RESOLUTION:-1920x1080}}
173239
DPI=\${2:-\${VNC_DPI:-96}}
@@ -204,8 +270,7 @@ echo -e "\nSuccess!\n"
204270
EOF
205271

206272
# Container ENTRYPOINT script
207-
tee /usr/local/share/desktop-init.sh > /dev/null \
208-
<< EOF
273+
cat << EOF > /usr/local/share/desktop-init.sh
209274
#!/bin/bash
210275
211276
USERNAME=${USERNAME}
@@ -286,11 +351,11 @@ sudoIf chown root:\${USERNAME} /tmp/.X11-unix
286351
if [ "\$(echo "\${VNC_RESOLUTION}" | tr -cd 'x' | wc -c)" = "1" ]; then VNC_RESOLUTION=\${VNC_RESOLUTION}x16; fi
287352
screen_geometry="\${VNC_RESOLUTION%*x*}"
288353
screen_depth="\${VNC_RESOLUTION##*x}"
289-
startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "tigervncserver \${DISPLAY} -geometry \${screen_geometry} -depth \${screen_depth} -rfbport \${VNC_PORT:-5901} -dpi \${VNC_DPI:-96} -localhost -desktop fluxbox -fg -passwd /usr/local/etc/vscode-dev-containers/vnc-passwd"
354+
startInBackgroundIfNotRunning "Xtigervnc" sudoUserIf "tigervncserver \${DISPLAY} -geometry \${screen_geometry} -depth \${screen_depth} -rfbport ${VNC_PORT} -dpi \${VNC_DPI:-96} -localhost -desktop fluxbox -fg -passwd /usr/local/etc/vscode-dev-containers/vnc-passwd"
290355
291356
# Spin up noVNC if installed and not runnning.
292357
if [ -d "/usr/local/novnc" ] && [ "\$(ps -ef | grep /usr/local/novnc/noVNC*/utils/launch.sh | grep -v grep)" = "" ]; then
293-
keepRunningInBackground "noVNC" sudoIf "/usr/local/novnc/noVNC*/utils/launch.sh --listen \${NOVNC_PORT:-6080} --vnc localhost:\${VNC_PORT:-5901}"
358+
keepRunningInBackground "noVNC" sudoIf "/usr/local/novnc/noVNC*/utils/launch.sh --listen ${NOVNC_PORT} --vnc localhost:${VNC_PORT}"
294359
log "noVNC started."
295360
else
296361
log "noVNC is already running or not installed."
@@ -303,61 +368,26 @@ log "** SCRIPT EXIT **"
303368
EOF
304369

305370
echo "${VNC_PASSWORD}" | vncpasswd -f > /usr/local/etc/vscode-dev-containers/vnc-passwd
306-
touch /root/.Xmodmap
307371
chmod +x /usr/local/share/desktop-init.sh /usr/local/bin/set-resolution
308372

309-
tee /root/.fluxbox/apps > /dev/null \
310-
<<EOF
311-
[transient] (role=GtkFileChooserDialog)
312-
[Dimensions] {70% 70%}
313-
[Position] (CENTER) {0 0}
314-
[end]
315-
EOF
373+
# Set up fluxbox config
374+
copy_fluxbox_config "/root"
375+
if [ "${USERNAME}" != "root" ]; then
376+
copy_fluxbox_config "/home/${USERNAME}"
377+
chown -R ${USERNAME} /home/${USERNAME}/.Xmodmap /home/${USERNAME}/.fluxbox
378+
fi
316379

317-
tee /root/.fluxbox/init > /dev/null \
318-
<<EOF
319-
session.configVersion: 13
320-
session.menuFile: ~/.fluxbox/menu
321-
session.keyFile: ~/.fluxbox/keys
322-
session.styleFile: /usr/share/fluxbox/styles/qnx-photon
323-
session.screen0.workspaces: 1
324-
session.screen0.workspacewarping: false
325-
session.screen0.toolbar.widthPercent: 100
326-
session.screen0.strftimeFormat: %a %l:%M %p
327-
session.screen0.toolbar.tools: RootMenu, clock, iconbar, systemtray
328-
session.screen0.workspaceNames: One,
329-
EOF
380+
cat << EOF
330381
331-
tee /root/.fluxbox/menu > /dev/null \
332-
<<EOF
333-
[begin] ( Application Menu )
334-
[exec] (File Manager) { nautilus ~ } <>
335-
[exec] (Text Editor) { mousepad } <>
336-
[exec] (Terminal) { tilix -w ~ -e $(readlink -f /proc/$$/exe) -il } <>
337-
[exec] (Web Browser) { x-www-browser --disable-dev-shm-usage } <>
338-
[submenu] (System) {}
339-
[exec] (Set Resolution) { tilix -t "Set Resolution" -e bash /usr/local/bin/set-resolution } <>
340-
[exec] (Edit Application Menu) { mousepad ~/.fluxbox/menu } <>
341-
[exec] (Passwords and Keys) { seahorse } <>
342-
[exec] (Top Processes) { tilix -t "Top" -e htop } <>
343-
[exec] (Disk Utilization) { tilix -t "Disk Utilization" -e ncdu / } <>
344-
[exec] (Editres) {editres} <>
345-
[exec] (Xfontsel) {xfontsel} <>
346-
[exec] (Xkill) {xkill} <>
347-
[exec] (Xrefresh) {xrefresh} <>
348-
[end]
349-
[config] (Configuration)
350-
[workspaces] (Workspaces)
351-
[end]
352-
EOF
353382
354-
# Set up non-root user (if one exists)
355-
if [ "${USERNAME}" != "root" ]; then
356-
touch /home/${USERNAME}/.Xmodmap
357-
cp -R /root/.fluxbox /home/${USERNAME}
358-
chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.Xmodmap /home/${USERNAME}/.fluxbox
359-
chown ${USERNAME}:root /usr/local/share/desktop-init.sh /usr/local/bin/set-resolution /usr/local/etc/vscode-dev-containers/vnc-passwd
360-
fi
383+
You now have a working desktop! Connect to in one of the following ways:
384+
385+
- Forward port ${NOVNC_PORT} and use a web browser start the noVNC client (recommended)
386+
- Forward port ${VNC_PORT} using VS Code client and connect using a VNC Viewer
387+
388+
In both cases, use the password "${VNC_PASSWORD}" when connecting
361389
362-
echo "Done!"
390+
(*) Done!
391+
392+
EOF
363393

0 commit comments

Comments
 (0)