Skip to content

Commit b0667c5

Browse files
[desktop-lite] - vnc_resolution - set thru env var (devcontainers#1112)
* [desktop-lite] - vnc_resolution - set thru env var * mistake in scenarios.json corrected * small change of function addition in desktop-init.sh file * changes as requested (review pr) * changes as suggested
1 parent 28846e5 commit b0667c5

File tree

5 files changed

+113
-6
lines changed

5 files changed

+113
-6
lines changed

src/desktop-lite/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "desktop-lite",
3-
"version": "1.2.4",
3+
"version": "1.2.5",
44
"name": "Light-weight Desktop",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/desktop-lite",
66
"description": "Adds a lightweight Fluxbox based desktop to the container that can be accessed using a VNC viewer or the web. GUI-based commands executed from the built-in VS code terminal will open on the desktop automatically.",

src/desktop-lite/install.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,11 @@ user_name="${USERNAME}"
300300
group_name="$(id -gn ${USERNAME})"
301301
LOG=/tmp/container-init.log
302302
303-
export DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS:-"autolaunch:"}"
304-
export DISPLAY="${DISPLAY:-:1}"
305-
export VNC_RESOLUTION="${VNC_RESOLUTION:-1440x768x16}"
306-
export LANG="${LANG:-"en_US.UTF-8"}"
307-
export LANGUAGE="${LANGUAGE:-"en_US.UTF-8"}"
303+
export DBUS_SESSION_BUS_ADDRESS="\${DBUS_SESSION_BUS_ADDRESS:-"autolaunch:"}"
304+
export DISPLAY="\${DISPLAY:-:1}"
305+
export VNC_RESOLUTION="\${VNC_RESOLUTION:-1440x768x16}"
306+
export LANG="\${LANG:-"en_US.UTF-8"}"
307+
export LANGUAGE="\${LANGUAGE:-"en_US.UTF-8"}"
308308
309309
# Execute the command it not already running
310310
startInBackgroundIfNotRunning()

test/desktop-lite/scenarios.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,32 @@
44
"features": {
55
"desktop-lite": {}
66
}
7+
},
8+
"test_vnc_resolution_as_container_env_var": {
9+
"image": "ubuntu:noble",
10+
"features": {
11+
"desktop-lite": {}
12+
}
13+
,
14+
"containerEnv": {
15+
"VNC_RESOLUTION": "1920x1080x32"
16+
},
17+
"forwardPorts": [
18+
5901,
19+
6080
20+
]
21+
},
22+
"test_vnc_resolution_as_remote_env_var": {
23+
"image": "ubuntu:noble",
24+
"features": {
25+
"desktop-lite": {}
26+
},
27+
"remoteEnv": {
28+
"VNC_RESOLUTION": "1920x1080x32"
29+
},
30+
"forwardPorts": [
31+
5901,
32+
6080
33+
]
734
}
835
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library
6+
source dev-container-features-test-lib
7+
8+
GREEN='\033[0;32m'; NC='\033[0m'; RED='\033[0;31m'; YELLOW='\033[0;33m';
9+
10+
# Check if xtigervnc & noVnc processes are running after successful installation and initialization
11+
check_process_running() {
12+
port=$1
13+
# Get process id of process running on specific port
14+
PID=$(lsof -i :$port | awk 'NR==2 {print $2}')
15+
if [ -n "$PID" ]; then
16+
CMD=$(ps -p $PID -o cmd --no-headers)
17+
echo -e "${GREEN}Command running on port $port: ${YELLOW}$CMD${NC}"
18+
else
19+
echo -e "${RED}No process found listening on port $port.${NC}"
20+
exit 1
21+
fi
22+
}
23+
24+
check_w_config_resolution() {
25+
configResolution=$1
26+
actualResolution=$2
27+
28+
if echo "$1" | grep -q "$2"; then
29+
echo -e "\n👍👍 ${GREEN}Configured resolution i.e. ${YELLOW}$configResolution${GREEN} has been set as vnc resolution i.e. ${YELLOW}$actualResolution${GREEN} in container.${NC}"
30+
else
31+
echo -e "\n❌❌ ${GREEN}Configured resolution i.e. ${YELLOW}$configResolution${GREEN} couldn't be set as vnc resolution i.e. ${YELLOW}$actualResolution${GREEN} in container.${NC}"
32+
fi
33+
}
34+
35+
check "Whether xtigervnc is Running" check_process_running 5901
36+
resolution=$(ps -x -ww | grep Xtigervnc | awk "{for(i=1;i<=NF;i++) if (\$i ~ /-geometry/) {print \$(i+1); exit}}")
37+
check "xtigervnc resolution" bash -c '$resolution'
38+
check_w_config_resolution $VNC_RESOLUTION $resolution
39+
sleep 2
40+
check "Whether no_vnc is Running" check_process_running 6080
41+
42+
check "desktop-init-exists" bash -c "ls /usr/local/share/desktop-init.sh"
43+
check "log-exists" bash -c "ls /tmp/container-init.log"
44+
check "log file contents" bash -c "cat /tmp/container-init.log"
45+
46+
# Report result
47+
reportResults
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library
6+
source dev-container-features-test-lib
7+
8+
# Check if xtigervnc & noVnc processes are running after successful installation and initialization
9+
check_process_running() {
10+
port=$1
11+
# Get process id of process running on specific port
12+
PID=$(lsof -i :$port | awk 'NR==2 {print $2}')
13+
GREEN='\033[0;32m'; NC='\033[0m'; RED='\033[0;31m'; YELLOW='\033[0;33m';
14+
if [ -n "$PID" ]; then
15+
CMD=$(ps -p $PID -o cmd --no-headers)
16+
echo -e "${GREEN}Command running on port $port: ${YELLOW}$CMD${NC}"
17+
else
18+
echo -e "${RED}No process found listening on port $port.${NC}"
19+
exit 1
20+
fi
21+
}
22+
23+
check "Whether xtigervnc is Running" check_process_running 5901
24+
check "xtigervnc resolution" bash -c 'ps -x -ww | grep Xtigervnc | awk "{for(i=1;i<=NF;i++) if (\$i ~ /-geometry/) {print \$(i+1); exit}}"'
25+
sleep 2
26+
check "Whether no_vnc is Running" check_process_running 6080
27+
28+
check "desktop-init-exists" bash -c "ls /usr/local/share/desktop-init.sh"
29+
check "log-exists" bash -c "ls /tmp/container-init.log"
30+
check "log file contents" bash -c "cat /tmp/container-init.log"
31+
32+
# Report result
33+
reportResults

0 commit comments

Comments
 (0)