fix: address review feedback on desktop stack

This commit is contained in:
Harivansh Rathi 2026-04-10 00:08:46 +00:00
parent 221cbf0588
commit 5eb25834af
3 changed files with 72 additions and 25 deletions

View file

@ -84,13 +84,14 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
fonts-noto-core \
fonts-noto-color-emoji \
dbus-user-session \
xclip \
&& rm -rf /var/lib/apt/lists/*
# Chromium: Ubuntu 24.04 only ships a snap stub, so pull the real .deb from
# the Debian Sid repo (pinned low so it only satisfies chromium itself).
RUN printf '%s\n' \
"deb [arch=amd64] http://deb.debian.org/debian sid main" \
# the Debian Sid repo with proper GPG key verification.
RUN curl -fsSL https://ftp-master.debian.org/keys/archive-key-12.asc \
| gpg --dearmor -o /etc/apt/keyrings/debian-archive.gpg \
&& printf '%s\n' \
"deb [arch=amd64 signed-by=/etc/apt/keyrings/debian-archive.gpg] http://deb.debian.org/debian sid main" \
>/etc/apt/sources.list.d/debian-sid.list \
&& printf '%s\n' \
"Package: *" \

View file

@ -6,15 +6,11 @@
</property>
<property name="backdrop" type="empty">
<property name="screen0" type="empty">
<property name="monitor0" type="empty">
<property name="image-path" type="string" value="/opt/desktop/assets/wallpaper.png"/>
<property name="monitorscreen" type="empty">
<property name="workspace0" type="empty">
<property name="last-image" type="string" value="/opt/desktop/assets/wallpaper.png"/>
<property name="image-style" type="int" value="5"/>
<property name="image-show" type="bool" value="true"/>
</property>
<property name="monitor1" type="empty">
<property name="image-path" type="string" value="/opt/desktop/assets/wallpaper.png"/>
<property name="image-style" type="int" value="5"/>
<property name="image-show" type="bool" value="true"/>
</property>
</property>
</property>

View file

@ -28,12 +28,24 @@ cleanup() {
[ -n "${websockify_pid:-}" ] && kill "$websockify_pid" >/dev/null 2>&1 || true
[ -n "${x11vnc_pid:-}" ] && kill "$x11vnc_pid" >/dev/null 2>&1 || true
[ -n "${plank_pid:-}" ] && kill "$plank_pid" >/dev/null 2>&1 || true
[ -n "${autocutsel_clip_pid:-}" ] && kill "$autocutsel_clip_pid" >/dev/null 2>&1 || true
[ -n "${autocutsel_pri_pid:-}" ] && kill "$autocutsel_pri_pid" >/dev/null 2>&1 || true
[ -n "${xfce_pid:-}" ] && kill "$xfce_pid" >/dev/null 2>&1 || true
[ -n "${dbus_pid:-}" ] && kill "$dbus_pid" >/dev/null 2>&1 || true
[ -n "${xvfb_pid:-}" ] && kill "$xvfb_pid" >/dev/null 2>&1 || true
wait >/dev/null 2>&1 || true
exit 0
}
# Start a persistent D-Bus session and export its address so all child
# processes (XFCE, Plank, autocutsel) share the same bus.
start_dbus() {
log "starting dbus session"
eval "$(dbus-launch --sh-syntax)"
export DBUS_SESSION_BUS_ADDRESS
dbus_pid="$DBUS_SESSION_BUS_PID"
}
start_xfce() {
reap_if_needed "${xfce_pid:-}"
log "starting xfce4-session"
@ -43,18 +55,47 @@ start_xfce() {
XDG_CURRENT_DESKTOP="$XDG_CURRENT_DESKTOP" \
XDG_SESSION_DESKTOP="$XDG_SESSION_DESKTOP" \
XDG_CONFIG_HOME="$XDG_CONFIG_HOME" \
dbus-launch --exit-with-session xfce4-session >>/tmp/xfce.log 2>&1 &
DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS" \
xfce4-session >>/tmp/xfce.log 2>&1 &
xfce_pid=$!
}
wait_for_wm() {
local i
for i in $(seq 1 50); do
if xprop -root -display "$DISPLAY" _NET_SUPPORTING_WM_CHECK >/dev/null 2>&1; then
return 0
fi
sleep 0.1
done
log "warning: window manager did not appear within 5s"
return 1
}
start_plank() {
reap_if_needed "${plank_pid:-}"
log "starting plank"
runuser -u node -- env DISPLAY="$DISPLAY" XDG_CONFIG_HOME="$XDG_CONFIG_HOME" \
runuser -u node -- env \
DISPLAY="$DISPLAY" \
XDG_CONFIG_HOME="$XDG_CONFIG_HOME" \
DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS" \
plank >>/tmp/plank.log 2>&1 &
plank_pid=$!
}
start_clipboard() {
if ! command -v autocutsel >/dev/null 2>&1; then
return
fi
reap_if_needed "${autocutsel_clip_pid:-}"
reap_if_needed "${autocutsel_pri_pid:-}"
log "starting clipboard sync"
runuser -u node -- env DISPLAY="$DISPLAY" autocutsel -selection CLIPBOARD -fork >>/tmp/autocutsel.log 2>&1
autocutsel_clip_pid=$(pgrep -n -u node autocutsel)
runuser -u node -- env DISPLAY="$DISPLAY" autocutsel -selection PRIMARY -fork >>/tmp/autocutsel.log 2>&1
autocutsel_pri_pid=$(pgrep -n -u node -f 'autocutsel.*PRIMARY')
}
start_x11vnc() {
reap_if_needed "${x11vnc_pid:-}"
log "starting x11vnc"
@ -69,6 +110,18 @@ start_websockify() {
websockify_pid=$!
}
# Restart the full desktop session (XFCE + Plank + clipboard) on the same
# D-Bus so all components share one session bus.
restart_desktop_session() {
[ -n "${plank_pid:-}" ] && kill "$plank_pid" >/dev/null 2>&1 || true
[ -n "${autocutsel_clip_pid:-}" ] && kill "$autocutsel_clip_pid" >/dev/null 2>&1 || true
[ -n "${autocutsel_pri_pid:-}" ] && kill "$autocutsel_pri_pid" >/dev/null 2>&1 || true
start_xfce
wait_for_wm || true
start_plank
start_clipboard
}
trap cleanup INT TERM
# Apply desktop profile on first boot
@ -102,19 +155,17 @@ fi
# Disable screensaver/DPMS
xset -display "$DISPLAY" -dpms s off s noblank >/dev/null 2>&1 || true
# Start persistent D-Bus session shared by all desktop components
start_dbus
# Start desktop stack
start_xfce
sleep 2
wait_for_wm || true
start_plank
start_clipboard
start_x11vnc
start_websockify
# Clipboard sync
if command -v autocutsel >/dev/null 2>&1; then
runuser -u node -- env DISPLAY="$DISPLAY" autocutsel -selection CLIPBOARD -fork >>/tmp/autocutsel.log 2>&1 || true
runuser -u node -- env DISPLAY="$DISPLAY" autocutsel -selection PRIMARY -fork >>/tmp/autocutsel.log 2>&1 || true
fi
# Monitor and restart dead processes
while true; do
if ! pid_running "$xvfb_pid"; then
@ -123,9 +174,8 @@ while true; do
exit 1
fi
if ! pid_running "${xfce_pid:-}"; then
log "xfce4-session exited; restarting"
start_xfce
sleep 2
log "xfce4-session exited; restarting desktop session"
restart_desktop_session
fi
if ! pid_running "${plank_pid:-}"; then
log "plank exited; restarting"