launcher.sh 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. #!/usr/bin/env bash
  2. # Hermes Bot Desktop — one headless Xfce desktop per Hermes profile, served over RFB.
  3. #
  4. # Spawned by tools/bot_desktop/runtime.py with HERMES_BD_* variables set. Runs TigerVNC's Xvnc
  5. # (X server + RFB server in one process; damage-driven, resizable via SetDesktopSize) listening on a
  6. # 0600 Unix socket only, then a minimal Xfce started component-wise under a private dbus session.
  7. #
  8. # Why not startxfce4 / xfce4-session: xfce4-session expects a logind session scope; outside one it
  9. # spawns polkit agents that pop empty dialogs and light-locker/xfce4-screensaver lock the desktop for a
  10. # user who has no password. Starting xfsettingsd -> xfwm4 -> xfdesktop -> xfce4-panel directly, with
  11. # the screensaver/locker/power-manager autostarts masked, is the shape every headless-VNC recipe
  12. # converges on (TigerVNC #1096/#581, OpenOnDemand's apptainer desktop, the Arch wiki).
  13. #
  14. # Why not the xfce4 metapackage: it drags in the screensaver, power manager and polkit agent this
  15. # script exists to keep out.
  16. set -euo pipefail
  17. : "${HERMES_BD_PROFILE:?}" # profile name (display name in the VNC title)
  18. : "${HERMES_BD_DISPLAY_NUM:?}" # allocated by runtime.py
  19. : "${HERMES_BD_SOCKET:?}" # RFB unix socket path
  20. : "${HERMES_BD_XAUTH:?}" # Xauthority path
  21. : "${HERMES_BD_ENV_FILE:?}" # where to publish DISPLAY/XAUTHORITY/DBUS_SESSION_BUS_ADDRESS
  22. : "${HERMES_BD_CONFIG_HOME:?}" # per-profile XDG_CONFIG_HOME (xfconf lives here)
  23. GEOM="${HERMES_BD_GEOMETRY:-1440x900}"
  24. DEPTH=24
  25. export XDG_CONFIG_HOME="$HERMES_BD_CONFIG_HOME"
  26. export XDG_CACHE_HOME="${HERMES_BD_CACHE_HOME:-$HERMES_BD_CONFIG_HOME/.cache}"
  27. export XDG_DATA_HOME="${HERMES_BD_DATA_HOME:-$HERMES_BD_CONFIG_HOME/.local-share}"
  28. export XDG_SESSION_TYPE=x11 XDG_CURRENT_DESKTOP=XFCE
  29. export GDK_BACKEND=x11 QT_QPA_PLATFORM=xcb NO_AT_BRIDGE=1 GTK_A11Y=none
  30. export LANG="${LANG:-C.UTF-8}"
  31. # Inheriting a login session's bus/session manager yields "Another session manager is already
  32. # running" / "Unable to contact settings server".
  33. unset SESSION_MANAGER DBUS_SESSION_BUS_ADDRESS DISPLAY XAUTHORITY WAYLAND_DISPLAY
  34. mkdir -p "$XDG_CONFIG_HOME/xfce4/xfconf/xfce-perchannel-xml" "$XDG_CONFIG_HOME/autostart" \
  35. "$XDG_CACHE_HOME" "$XDG_DATA_HOME" "$(dirname "$HERMES_BD_SOCKET")"
  36. export DISPLAY=":$HERMES_BD_DISPLAY_NUM"
  37. export XAUTHORITY="$HERMES_BD_XAUTH"
  38. # Stale lock files from a crashed server block restart; a lock whose pid is alive belongs to a
  39. # running server (another profile may have taken this number) and is never touched — Xvnc then
  40. # fails to start on it and runtime.py reports that instead of us disrupting the other desktop.
  41. rm -f "$HERMES_BD_SOCKET"
  42. # no-tmp: ok — the X11 protocol fixes its lock and socket under /tmp; this is not our scratch dir
  43. xlock="/tmp/.X${HERMES_BD_DISPLAY_NUM}-lock"
  44. if [[ -e "$xlock" ]] && ! kill -0 "$(tr -d ' ' < "$xlock" 2>/dev/null)" 2>/dev/null; then
  45. rm -f "$xlock" "/tmp/.X11-unix/X${HERMES_BD_DISPLAY_NUM}" # no-tmp: ok — X11 display socket, fixed by the protocol
  46. fi
  47. : > "$XAUTHORITY"; chmod 600 "$XAUTHORITY"
  48. # The cookie goes in on stdin, not argv: a command line is readable by every local user via ps.
  49. xauth -q -f "$XAUTHORITY" source - <<COOKIE
  50. add $DISPLAY MIT-MAGIC-COOKIE-1 $(od -An -N16 -tx1 /dev/urandom | tr -d ' \n')
  51. COOKIE
  52. # ---- look: dark theme from whatever the host ships (first match wins), Hermes wallpaper ----
  53. pick_theme() { local d t; for t in "$@"; do for d in /usr/share/themes "$HOME/.themes"; do [[ -d "$d/$t" ]] && { echo "$t"; return; }; done; done; echo "$1"; }
  54. pick_icons() { local d t; for t in "$@"; do for d in /usr/share/icons "$HOME/.icons"; do [[ -d "$d/$t" ]] && { echo "$t"; return; }; done; done; echo "$1"; }
  55. GTK_THEME_NAME=$(pick_theme Adwaita-dark Breeze-Dark Greybird-dark Arc-Dark Adwaita)
  56. WM_THEME_NAME=$(pick_theme Default-hdpi Default) # xfwm4 window themes ship with xfwm4 itself
  57. ICON_THEME_NAME=$(pick_icons Papirus-Dark breeze-dark Adwaita hicolor)
  58. : "${HERMES_BD_WALLPAPER:="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/wallpaper.png"}"
  59. # ---- pre-seed xfconf BEFORE xfconfd starts (it caches; edits after start are overwritten) ----
  60. X="$XDG_CONFIG_HOME/xfce4/xfconf/xfce-perchannel-xml"
  61. [[ -e "$X/xfwm4.xml" ]] || cat > "$X/xfwm4.xml" <<'EOF'
  62. <?xml version="1.0" encoding="UTF-8"?>
  63. <channel name="xfwm4" version="1.0">
  64. <property name="general" type="empty">
  65. <property name="use_compositing" type="bool" value="false"/>
  66. <property name="workspace_count" type="int" value="1"/>
  67. <property name="focus_new" type="bool" value="true"/>
  68. <property name="theme" type="string" value="HERMES_BD_WM_THEME"/>
  69. <property name="title_font" type="string" value="DejaVu Sans Bold 9"/>
  70. </property>
  71. </channel>
  72. EOF
  73. sed -i "s|HERMES_BD_WM_THEME|$WM_THEME_NAME|" "$X/xfwm4.xml"
  74. [[ -e "$X/xfce4-screensaver.xml" ]] || cat > "$X/xfce4-screensaver.xml" <<'EOF'
  75. <?xml version="1.0" encoding="UTF-8"?>
  76. <channel name="xfce4-screensaver" version="1.0">
  77. <property name="saver" type="empty"><property name="enabled" type="bool" value="false"/></property>
  78. <property name="lock" type="empty"><property name="enabled" type="bool" value="false"/></property>
  79. </channel>
  80. EOF
  81. [[ -e "$X/xsettings.xml" ]] || cat > "$X/xsettings.xml" <<'EOF'
  82. <?xml version="1.0" encoding="UTF-8"?>
  83. <channel name="xsettings" version="1.0">
  84. <property name="Net" type="empty">
  85. <property name="EnableEventSounds" type="bool" value="false"/>
  86. <property name="ThemeName" type="string" value="HERMES_BD_GTK_THEME"/>
  87. <property name="IconThemeName" type="string" value="HERMES_BD_ICON_THEME"/>
  88. </property>
  89. <property name="Gtk" type="empty">
  90. <property name="FontName" type="string" value="DejaVu Sans 10"/>
  91. <property name="MonospaceFontName" type="string" value="DejaVu Sans Mono 10"/>
  92. </property>
  93. <property name="Xft" type="empty">
  94. <property name="DPI" type="int" value="96"/>
  95. <property name="Antialias" type="int" value="1"/>
  96. <property name="Hinting" type="int" value="1"/>
  97. </property>
  98. </channel>
  99. EOF
  100. sed -i "s|HERMES_BD_GTK_THEME|$GTK_THEME_NAME|; s|HERMES_BD_ICON_THEME|$ICON_THEME_NAME|" "$X/xsettings.xml"
  101. [[ -e "$X/xfce4-desktop.xml" ]] || cat > "$X/xfce4-desktop.xml" <<'EOF'
  102. <?xml version="1.0" encoding="UTF-8"?>
  103. <channel name="xfce4-desktop" version="1.0">
  104. <property name="backdrop" type="empty">
  105. <property name="screen0" type="empty">
  106. <property name="monitorVNC-0" type="empty">
  107. <property name="workspace0" type="empty">
  108. <property name="color-style" type="int" value="0"/>
  109. <property name="image-style" type="int" value="5"/>
  110. <property name="last-image" type="string" value="HERMES_BD_WALLPAPER_PLACEHOLDER"/>
  111. <property name="rgba1" type="array">
  112. <value type="double" value="0.11"/><value type="double" value="0.12"/>
  113. <value type="double" value="0.16"/><value type="double" value="1"/>
  114. </property>
  115. </property>
  116. </property>
  117. </property>
  118. </property>
  119. <property name="desktop-icons" type="empty">
  120. <property name="style" type="int" value="0"/>
  121. </property>
  122. </channel>
  123. EOF
  124. sed -i "s|HERMES_BD_WALLPAPER_PLACEHOLDER|$HERMES_BD_WALLPAPER|" "$X/xfce4-desktop.xml"
  125. # Own panel layout (a layout on disk also suppresses the first-run "Welcome to the panel" dialog):
  126. # top bar = menu · tasks · tray · clock; bottom dock = only launchers whose program exists on this
  127. # host, the browser pinned to the one the bot drives so a human lands in the bot's own browser profile.
  128. if [[ ! -e "$X/xfce4-panel.xml" ]]; then
  129. L="$XDG_CONFIG_HOME/xfce4/panel"; mkdir -p "$L"
  130. dock_ids=(); n=20
  131. add_launcher() { # name icon executable [Exec= line] — skipped when the executable is missing.
  132. # The Exec= line is passed ready-made (spec-quoted by Python) so paths with spaces survive; a bare
  133. # program name is its own Exec= value.
  134. command -v "$3" >/dev/null 2>&1 || return 0
  135. n=$((n+1)); mkdir -p "$L/launcher-$n"
  136. printf '[Desktop Entry]\nVersion=1.0\nType=Application\nName=%s\nIcon=%s\n%s\nTerminal=false\nStartupNotify=false\n' \
  137. "$1" "$2" "${4:-Exec=$3}" > "$L/launcher-$n/hermes.desktop"
  138. dock_ids+=("$n")
  139. }
  140. add_launcher "Terminal" utilities-terminal "xfce4-terminal"
  141. # The bot's browser: runtime.py resolves the executable the agent's browser runs plus the profile's
  142. # persistent user-data-dir, so a human taking over lands in the bot's own cookie jar.
  143. [[ -n "${HERMES_BD_BROWSER_EXEC:-}" ]] && \
  144. add_launcher "Browser" internet-web-browser "$HERMES_BD_BROWSER_EXEC" "${HERMES_BD_BROWSER_EXEC_LINE:-}" && \
  145. echo "$n" > "$L/.hermes-browser-launcher"
  146. add_launcher "Files" system-file-manager "thunar"
  147. add_launcher "Text Editor" accessories-text-editor "mousepad"
  148. dock_plugins=""; dock_items=""
  149. for id in "${dock_ids[@]}"; do
  150. dock_plugins+="<value type=\"int\" value=\"$id\"/>"
  151. dock_items+="<property name=\"plugin-$id\" type=\"string\" value=\"launcher\"><property name=\"items\" type=\"array\"><value type=\"string\" value=\"hermes.desktop\"/></property></property>"
  152. done
  153. cat > "$X/xfce4-panel.xml" <<PANEL
  154. <?xml version="1.0" encoding="UTF-8"?>
  155. <channel name="xfce4-panel" version="1.0">
  156. <property name="configver" type="int" value="2"/>
  157. <property name="panels" type="array">
  158. <value type="int" value="1"/>
  159. <value type="int" value="2"/>
  160. <property name="dark-mode" type="bool" value="true"/>
  161. <property name="panel-1" type="empty">
  162. <property name="position" type="string" value="p=6;x=0;y=0"/>
  163. <property name="length" type="uint" value="100"/>
  164. <property name="position-locked" type="bool" value="true"/>
  165. <property name="size" type="uint" value="28"/>
  166. <property name="icon-size" type="uint" value="16"/>
  167. <property name="background-style" type="uint" value="1"/>
  168. <property name="background-rgba" type="array">
  169. <value type="double" value="0.06"/><value type="double" value="0.07"/>
  170. <value type="double" value="0.09"/><value type="double" value="0.92"/>
  171. </property>
  172. <property name="plugin-ids" type="array">
  173. <value type="int" value="1"/><value type="int" value="2"/><value type="int" value="3"/>
  174. <value type="int" value="4"/><value type="int" value="5"/>
  175. </property>
  176. </property>
  177. <property name="panel-2" type="empty">
  178. <property name="position" type="string" value="p=10;x=0;y=0"/>
  179. <property name="length" type="uint" value="1"/>
  180. <property name="length-adjust" type="bool" value="true"/>
  181. <property name="position-locked" type="bool" value="true"/>
  182. <property name="size" type="uint" value="44"/>
  183. <property name="icon-size" type="uint" value="28"/>
  184. <property name="background-style" type="uint" value="1"/>
  185. <property name="background-rgba" type="array">
  186. <value type="double" value="0.06"/><value type="double" value="0.07"/>
  187. <value type="double" value="0.09"/><value type="double" value="0.80"/>
  188. </property>
  189. <property name="plugin-ids" type="array">${dock_plugins}</property>
  190. </property>
  191. </property>
  192. <property name="plugins" type="empty">
  193. <property name="plugin-1" type="string" value="applicationsmenu">
  194. <property name="show-button-title" type="bool" value="false"/>
  195. </property>
  196. <property name="plugin-2" type="string" value="tasklist">
  197. <property name="grouping" type="bool" value="true"/>
  198. <property name="show-labels" type="bool" value="true"/>
  199. </property>
  200. <property name="plugin-3" type="string" value="separator">
  201. <property name="expand" type="bool" value="true"/>
  202. <property name="style" type="uint" value="0"/>
  203. </property>
  204. <property name="plugin-4" type="string" value="systray"/>
  205. <property name="plugin-5" type="string" value="clock">
  206. <property name="digital-time-format" type="string" value="%a %H:%M"/>
  207. </property>
  208. ${dock_items}
  209. </property>
  210. </channel>
  211. PANEL
  212. fi
  213. # Mask system autostarts that want logind/polkit/keyring/at-spi.
  214. for a in xfce4-screensaver light-locker xfce4-power-manager xfce-polkit \
  215. polkit-gnome-authentication-agent-1 lxpolkit xfce4-notifyd blueman at-spi-dbus-bus \
  216. gnome-keyring-pkcs11 gnome-keyring-secrets gnome-keyring-ssh xdg-user-dirs; do
  217. [[ -e "$XDG_CONFIG_HOME/autostart/$a.desktop" ]] || \
  218. printf '[Desktop Entry]\nType=Application\nName=%s\nHidden=true\n' "$a" > "$XDG_CONFIG_HOME/autostart/$a.desktop"
  219. done
  220. # The Browser launcher's Exec= line binds the bot's user-data-dir by absolute path. The panel layout is
  221. # seeded once (the human may have rearranged it), but this one line is ours and must follow the profile:
  222. # after `hermes profile rename` the old path would open a browser with an empty, unshared cookie jar.
  223. L="$XDG_CONFIG_HOME/xfce4/panel"
  224. # Profiles seeded before the marker existed have the launcher but no `.hermes-browser-launcher`; recover
  225. # it from our own Browser entry (hermes.desktop is ours by name) so their Exec= follows a rename too.
  226. if [[ -n "${HERMES_BD_BROWSER_EXEC:-}" && -n "${HERMES_BD_BROWSER_EXEC_LINE:-}" && ! -r "$L/.hermes-browser-launcher" ]]; then
  227. for d in "$L"/launcher-*/hermes.desktop; do
  228. [[ -f "$d" ]] || continue
  229. while IFS= read -r line; do
  230. if [[ "$line" == "Name=Browser" ]]; then
  231. bn="${d%/hermes.desktop}"; bn="${bn##*/launcher-}"
  232. printf '%s\n' "$bn" > "$L/.hermes-browser-launcher"; break 2
  233. fi
  234. done < "$d"
  235. done
  236. fi
  237. if [[ -n "${HERMES_BD_BROWSER_EXEC:-}" && -n "${HERMES_BD_BROWSER_EXEC_LINE:-}" && -r "$L/.hermes-browser-launcher" ]]; then
  238. bn="$(cat "$L/.hermes-browser-launcher")"
  239. d="$L/launcher-$bn/hermes.desktop"
  240. [[ -f "$d" ]] && sed -i "s|^Exec=.*|$(printf '%s' "$HERMES_BD_BROWSER_EXEC_LINE" | sed 's/[&|\\]/\\&/g')|" "$d"
  241. fi
  242. # Tests seed the config tree on a fake PATH and stop here (no X server needed).
  243. [[ -n "${HERMES_BD_SEED_ONLY:-}" ]] && exit 0
  244. # ---- X server + RFB (TigerVNC Xvnc), Unix socket only ----
  245. # SecurityTypes None is safe ONLY because -rfbport -1 disables TCP and the 0600 socket is reachable
  246. # only by processes running as this user (the gateway's WebSocket bridge does the real authentication;
  247. # same-UID processes, the bot's own terminal tool included, are inside that boundary by design).
  248. # -SendCutText=0: watchers must never receive the holder's clipboard; -AcceptCutText stays on so
  249. # paste INTO the screen keeps working. -MaxCutText caps a client cut-text at 256 KiB — the same bound
  250. # the bridge enforces (tools/bot_desktop/rfb_filter.py _MAX_CUT_TEXT); keep the two in sync.
  251. Xvnc "$DISPLAY" -geometry "$GEOM" -depth "$DEPTH" -dpi 96 \
  252. -rfbport -1 -rfbunixpath "$HERMES_BD_SOCKET" -rfbunixmode 0600 \
  253. -SecurityTypes None -AlwaysShared -AcceptSetDesktopSize -FrameRate 30 -SendCutText=0 -MaxCutText 262144 \
  254. -desktop "hermes:$HERMES_BD_PROFILE" -auth "$XAUTHORITY" -nolisten tcp \
  255. -Log '*:stderr:30' 2> >(grep -v --line-buffered 'Could not resolve keysym' >&2) &
  256. XVNC_PID=$!
  257. trap 'kill "$XVNC_PID" 2>/dev/null || true' EXIT
  258. for _ in $(seq 1 100); do
  259. xdpyinfo -display "$DISPLAY" >/dev/null 2>&1 && break
  260. kill -0 "$XVNC_PID" 2>/dev/null || { echo "Xvnc exited during startup" >&2; exit 1; }
  261. sleep 0.1
  262. done
  263. xdpyinfo -display "$DISPLAY" >/dev/null 2>&1 || { echo "Xvnc did not become ready" >&2; exit 1; }
  264. setxkbmap -display "$DISPLAY" us 2>/dev/null || true # RFB keysyms + xdotool assume a known layout
  265. xsetroot -display "$DISPLAY" -solid '#1c1f29' 2>/dev/null || true
  266. xset -display "$DISPLAY" s off -dpms s noblank 2>/dev/null || true
  267. # ---- idle self-stop: the screen outlives the gateway that started it (a restarted gateway re-attaches),
  268. # so it must also stop itself when no gateway ever comes back. tools/bot_desktop/idle_watch.py applies the
  269. # gateway watcher's own rule (bot_desktop.idle_stop_minutes; never while a human is using the screen) once per
  270. # run and prints the seconds until the next check; nothing stays resident in between. runtime.py passes the
  271. # install's command for it, shell-quoted (the launcher's pid is appended); skipped when it passed none (the
  272. # sandbox-hosted screen, whose sandbox lifetime bounds it).
  273. WATCH_PID=
  274. if [[ -n "${HERMES_BD_IDLE_CMD:-}" ]]; then
  275. # A start is use: stamp it now, or an activity file left by an earlier screen could make the first check
  276. # stop this one before runtime.py stamps it.
  277. touch "$(dirname "$HERMES_BD_ENV_FILE")/activity"
  278. # The TERM trap ends this loop at once when the screen goes down (stop()'s group signal or the EXIT trap
  279. # below). Both the check and the sleep run in the background and are waited on, because `wait` is
  280. # interruptible: a `$(check)` would defer the trap until the check returns, while a check that is itself
  281. # stopping the screen waits for this group to empty, so every self-stop would sit out stop()'s grace and
  282. # end in SIGKILL with start.lock held. The check is in a session of its own and finishes the stop alone.
  283. # Sleep first: a screen just started cannot be idle, so the first check is due a window from now
  284. # (runtime.py passes that delay), not while Xfce is still coming up.
  285. (
  286. # Not under the launcher's `set -e`: a sleep or check killed from outside (a stray pkill, the OOM killer)
  287. # makes `wait` fail, and that must cost at most one slow retry, not the self-stop for the rest of the screen's life.
  288. set +e
  289. sleeper=
  290. trap 'kill $sleeper 2>/dev/null; exit 0' TERM
  291. out="$(dirname "$HERMES_BD_ENV_FILE")/idle-watch.out"
  292. delay="${HERMES_BD_IDLE_FIRST_DELAY:-300}"
  293. while :; do
  294. [[ "$delay" =~ ^[0-9]+$ ]] || delay=300
  295. sleep "$delay" & sleeper=$!
  296. # Killed (status > 128): check now. A sleep that cannot sleep at all would spin the check: give up.
  297. wait "$sleeper" || (( $? > 128 )) || { echo "idle self-stop: sleep failed; off for this screen" >&2; exit 0; }
  298. sleeper=
  299. kill -0 "$$" 2>/dev/null || exit 0
  300. eval "set -- $HERMES_BD_IDLE_CMD"
  301. HERMES_HOME="$HERMES_BD_HOME" "$@" "$$" >"$out" &
  302. if wait "$!"; then delay=$(<"$out"); else delay=300; fi # broken check: retry slowly
  303. [[ -n "$delay" ]] || exit 0 # it stopped the screen
  304. done
  305. ) &
  306. WATCH_PID=$!
  307. fi
  308. trap 'kill "$XVNC_PID" $WATCH_PID 2>/dev/null || true' EXIT
  309. # ---- private session bus + Xfce components (no xfce4-session) ----
  310. # dbus-run-session scopes the bus to this subshell: no leaked dbus-daemons on restart. The env file
  311. # is written from INSIDE the bus so DBUS_SESSION_BUS_ADDRESS is the real one; runtime.py and every
  312. # cua-driver / browser spawn for this profile source it.
  313. # Not exec'd: this script stays the supervisor so the EXIT trap above still reaps Xvnc when the Xfce
  314. # session dies on its own (exec would replace the trap's owner and orphan the X server).
  315. dbus-run-session -- bash -c '
  316. set -e
  317. umask 077
  318. printf "DISPLAY=%s\nXAUTHORITY=%s\nDBUS_SESSION_BUS_ADDRESS=%s\nXDG_CONFIG_HOME=%s\nXDG_CACHE_HOME=%s\nXDG_DATA_HOME=%s\n" \
  319. "$DISPLAY" "$XAUTHORITY" "$DBUS_SESSION_BUS_ADDRESS" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME" "$XDG_DATA_HOME" \
  320. > "$HERMES_BD_ENV_FILE.tmp" && mv -f "$HERMES_BD_ENV_FILE.tmp" "$HERMES_BD_ENV_FILE"
  321. xfsettingsd --sm-client-disable --daemon 2>/dev/null || true
  322. xfwm4 --compositor=off --sm-client-disable &
  323. for _ in $(seq 1 50); do xprop -root _NET_SUPPORTING_WM_CHECK >/dev/null 2>&1 && break; sleep 0.1; done
  324. xfdesktop --sm-client-disable --disable-wm-check &
  325. exec xfce4-panel --sm-client-disable --disable-wm-check
  326. ' && rc=0 || rc=$?
  327. kill "$XVNC_PID" 2>/dev/null || true
  328. exit "$rc"