Skip to content

Commit 9342279

Browse files
authored
Set desktop background using custom sandbox template (#57)
* Organize and simplify Dockerfile * Fix missing command * Remove unnecessary sudo * Set desktop background using custom sandbox template instead of at runtime
1 parent cf0d845 commit 9342279

4 files changed

Lines changed: 20 additions & 12 deletions

File tree

packages/js-sdk/src/sandbox.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ export class Sandbox extends SandboxBase {
115115
private lastXfce4Pid: number | null = null;
116116
readonly display: string;
117117
readonly stream: VNCServer;
118-
private readonly changeWallpaperCmd: string = (
119-
`xfconf-query --create -t string -c xfce4-desktop -p ` +
120-
`/backdrop/screen0/monitorscreen/workspace0/last-image -s /usr/share/backgrounds/xfce/wallpaper.png`
121-
)
122118

123119
/**
124120
* Use {@link Sandbox.create} to create a new Sandbox instead.
@@ -264,7 +260,6 @@ export class Sandbox extends SandboxBase {
264260
"startxfce4", { envs: { DISPLAY: this.display }, background: true }
265261
);
266262
this.lastXfce4Pid = result.pid;
267-
await this.commands.run(this.changeWallpaperCmd, { envs: { DISPLAY: this.display } });
268263
}
269264
}
270265

packages/python-sdk/e2b_desktop/main.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,6 @@ def stop(self) -> None:
171171

172172
class Sandbox(SandboxBase):
173173
default_template = "desktop"
174-
change_wallpaper_cmd = (
175-
"xfconf-query --create -t string -c xfce4-desktop -p "
176-
"/backdrop/screen0/monitorscreen/workspace0/last-image -s /usr/share/backgrounds/xfce/wallpaper.png"
177-
)
178174

179175
def __init__(
180176
self,
@@ -272,7 +268,6 @@ def _start_xfce4(self):
272268
self._last_xfce4_pid = self.commands.run(
273269
"startxfce4", envs={"DISPLAY": self._display}, background=True
274270
).pid
275-
self.commands.run(self.change_wallpaper_cmd, envs={"DISPLAY": self._display})
276271

277272
@property
278273
def stream(self) -> _VNCServer:

template/e2b.Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ RUN \
4949
# ~ Make your changes to this template BELOW this line ~
5050

5151
# Set the default terminal
52-
RUN sudo ln -sf /usr/bin/xfce4-terminal.wrapper /etc/alternatives/x-terminal-emulator
52+
RUN ln -sf /usr/bin/xfce4-terminal.wrapper /etc/alternatives/x-terminal-emulator
5353

5454
# Install standard apps
5555
RUN apt-get install -y x11-apps \
@@ -77,4 +77,6 @@ RUN mkdir -p /home/user/.config/Code/User
7777
COPY ./settings.json /home/user/.config/Code/User/settings.json
7878

7979
# Copy desktop background for XFCE
80-
COPY ./wallpaper.png /usr/share/backgrounds/xfce/wallpaper.png
80+
COPY ./wallpaper.png /usr/share/backgrounds/xfce/wallpaper.png
81+
RUN mkdir -p /home/user/.config/xfce4/xfconf/xfce-perchannel-xml/
82+
COPY ./xfce4-desktop.xml /home/user/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml

template/xfce4-desktop.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<channel name="xfce4-desktop" version="1.0">
4+
<property name="backdrop" type="empty">
5+
<property name="screen0" type="empty">
6+
<property name="monitorscreen" type="empty">
7+
<property name="workspace0" type="empty">
8+
<property name="last-image" type="string"
9+
value="/usr/share/backgrounds/xfce/wallpaper.png" />
10+
<property name="color-style" type="int" value="0" />
11+
<property name="image-style" type="int" value="5" />
12+
</property>
13+
</property>
14+
</property>
15+
</property>
16+
</channel>

0 commit comments

Comments
 (0)