diff --git a/FEATURES.md b/FEATURES.md
index 3724ae6..365d2b6 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -852,6 +852,7 @@ AnyBot 是一個桌面聊天 App,介面和運作方式照 Grok Bot 重做。
- **健康檢查**:每 20 秒看一次,單次最多等 3 秒(原版 /health 的逾時)。
- **Bot 在上面的權限**:這是它自己的電腦,所以指令、改檔案、操作螢幕都不用問你;只有「一律不允許」的指令(例如格式化)還是會擋。可以 `sudo` 安裝套件。
- **開機時間**:最多等 60 秒(估計值)。
+- **桌面**(第 12 版起,照 LazyBoy2 的 box;以前是 fluxbox,只有右鍵選單和一條細工作列,不好用):XFCE(xfwm4 視窗、xfdesktop 桌布、xfce4-panel 工作列,沒有工作階段管理員)。下方工作列:「應用程式」選單、「瀏覽器」、「檔案管理員」、「終端機」、開著的視窗、時鐘;桌面按右鍵也有應用程式選單。應用程式選單只有一層:瀏覽器、檔案管理員、終端機、文字編輯器、影像檢視器(Bot 另外裝的程式出現在「其他」);沒有 XFCE 的設定選項(每次開機照映像檔重放,而且大多要 XFCE 的設定服務才會生效)。這三個是 AnyBot 加的(LazyBoy2 沒有):檔案管理員是 Thunar(有縮圖;在檔案上按兩下:文字檔開文字編輯器 Mousepad、圖片開影像檢視器 Ristretto、PDF 和網頁開瀏覽器;按右鍵「在此開啟終端機」開在那個資料夾),側邊欄和網頁上傳檔案的視窗都有「下載」(/home/bot/Downloads,Bot 下載的檔案在這裡);瀏覽器下載完按「在資料夾中顯示」會開檔案管理員。工作列鎖住:按右鍵沒有移除、移動、屬性(只剩「面板 › 登出/說明/關於」);「登出」只會關掉工作列,一秒後自己回來。新視窗開在螢幕中間。網頁上傳檔案的視窗每次開機設成螢幕的七成寬、四分之三高(GTK 要同時記著位置才會照記住的大小開;沒有時照字型算,粉圓 12 號算出 1342×1029,比螢幕大,「開啟」掉到螢幕外)。Arc-Dark 深色主題、Papirus 圖示、jf open 粉圓字型(OFL,建映像檔時下載並核對 sha256),選單、瀏覽器和網頁語言都是繁體中文(LANG=zh_TW.UTF-8,沒設 LC_ALL,單一指令還能用 LANG=C),時區台北(/etc/localtime,沒有 TZ 變數)。選單裡瀏覽器和終端機各只有一個:瀏覽器一律是 `anybot-browser`,終端機是 `anybot-terminal`(xfce4-terminal,一個視窗一個程式,用桌面的 D-Bus)。開機就在共用螢幕開好瀏覽器,設定檔第一次用時開說明頁「這是 Bot 的電腦」。桌面設定每次開機都照映像檔重放。每個 Bot 自己的螢幕也是同一套桌面(各自的 D-Bus 和 xfconfd,讀同一份設定)。工作列和桌布不在 Bot 截圖的編號裡(看得到,但清單只列在用的視窗)。`docker stop` 時先讓瀏覽器正常關掉(最多 5 秒),剛登入的 cookie 才會寫進磁碟。
### 快照與三種更新(原版的規則)
@@ -1261,7 +1262,7 @@ AnyBot 是一個桌面聊天 App,介面和運作方式照 Grok Bot 重做。
computer_use_screenshot、click、mouse_move、mouse_button(按住/放開)、drag、scroll、typing、press_key、check_permissions。另外兩個:
- **(已併入截圖)「讀 App 畫面」**:按鈕清單現在就在每張截圖裡,不再是另一個工具。很長的內容(終端機的整段捲動紀錄)留開頭 160 字和結尾 400 字。
-- **「打開 App」(computer_use_open_app)**:打開或叫到最前面,顯示的名字也可以(「計算機」→ Calculator)。Bot 的電腦上:chromium(瀏覽器,就是 browser_* 在用的那個,不會開第二個)、xterm(終端機)或其他程式名稱。
+- **「打開 App」(computer_use_open_app)**:打開或叫到最前面,顯示的名字也可以(「計算機」→ Calculator)。Bot 的電腦上:chromium(瀏覽器,就是 browser_* 在用的那個,不會開第二個)、終端機(xfce4-terminal,跟工作列的「終端機」一樣;第 11 版以前是 xterm,xterm 照名字還打得開)、檔案管理員(也認「檔案總管」「Files」「Finder」等,開 Thunar,從家目錄開始)或其他程式名稱;回覆用 Bot 說的名字(「已打開「檔案管理員」」)。
- **(已拿掉)「按住或放開滑鼠」**:拖曳已經涵蓋。
- **「檢查螢幕權限」(computer_use_check_permissions)**:回報「螢幕錄製:已允許/還沒允許」「輔助使用(滑鼠和鍵盤):…」,不會跳出系統視窗。Bot 的電腦上一律可以。
diff --git a/bench/computer-use/run.py b/bench/computer-use/run.py
index ee21dfb..42b0fc7 100644
--- a/bench/computer-use/run.py
+++ b/bench/computer-use/run.py
@@ -177,7 +177,7 @@ TASKS = [
"setup": "ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime; rm -f /etc/timezone; "
"for f in /home/bot/.profile /home/bot/.bashrc /home/bot/.bash_profile /home/bot/.pam_environment /etc/environment /etc/profile.d/*tz* /etc/profile.d/*time*; do "
"[ -f \"$f\" ] && sed -i '/TZ=/d;/Asia\\/Tokyo/d' \"$f\"; done; "
- "grep -l 'TZ=' /proc/[0-9]*/environ 2>/dev/null | cut -d/ -f3 | xargs -r ps -o pid=,comm= -p | grep -E 'fluxbox|xterm' | awk '{print $1}' | xargs -r kill; sleep 1; "
+ "grep -l 'TZ=' /proc/[0-9]*/environ 2>/dev/null | cut -d/ -f3 | xargs -r ps -o pid=,comm= -p | grep -E 'fluxbox|xfce4-panel|xfce4-terminal|xterm' | awk '{print $1}' | xargs -r kill; sleep 1; "
"su bot -c 'date +%Z'",
"ask": "把你電腦的時區設成日本東京時間,設好後告訴我現在那台電腦顯示的時間。",
"check": lambda dh, ans: "Tokyo" in dx("readlink -f /etc/localtime; cat /etc/timezone 2>/dev/null", dh)[1]},
diff --git a/box/Dockerfile b/box/Dockerfile
index 23141a5..af9f41e 100644
--- a/box/Dockerfile
+++ b/box/Dockerfile
@@ -2,28 +2,93 @@
# (an X11 desktop driven by xdotool, watched through noVNC on port 6080). One TigerVNC server is
# the screen and the VNC server; AT-SPI is on, so every app's controls (web pages included) can
# be read with their places and numbered on the bot's picture (box/a11y, after XBot's box).
+# The desktop is LazyBoy2's box (was fluxbox, a bare menu on a right click): a minimal XFCE
+# (xfwm4 + xfdesktop + a panel with 應用程式, 瀏覽器, 終端機, the open windows and a clock),
+# Arc-Dark + Papirus + jf open 粉圓, Traditional Chinese menus, Taipei time. Not on LazyBoy2's:
+# 檔案管理員 (Thunar, with thumbnails), 文字編輯器 (Mousepad) and 影像檢視器 (Ristretto), so a
+# file a bot made or downloaded opens with a double click.
FROM debian:bookworm-slim
# No TZ here: a TZ variable overrides /etc/localtime for every program, so setting the timezone
-# the normal way (/etc/localtime, /etc/timezone) seemed to do nothing. /etc/localtime is UTC.
+# the normal way (/etc/localtime, /etc/timezone) seemed to do nothing. /etc/localtime is Taipei.
ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8
-RUN apt-get update && apt-get install -y --no-install-recommends \
- tigervnc-standalone-server tigervnc-tools xdotool x11-utils x11-xserver-utils imagemagick fluxbox xterm \
+# dpkg never unpacks docs, man pages or other languages' messages (zh_TW is kept: the XFCE menus
+# are in Traditional Chinese).
+RUN printf '%s\n' \
+ 'path-exclude=/usr/share/doc/*' \
+ 'path-include=/usr/share/doc/*/copyright' \
+ 'path-exclude=/usr/share/man/*' \
+ 'path-exclude=/usr/share/info/*' \
+ 'path-exclude=/usr/share/gtk-doc/*' \
+ 'path-exclude=/usr/share/backgrounds/*' \
+ 'path-exclude=/usr/share/locale/*' \
+ 'path-include=/usr/share/locale/locale.alias' \
+ 'path-include=/usr/share/locale/zh_TW/*' \
+ 'path-include=/usr/share/locale/zh/*' \
+ > /etc/dpkg/dpkg.cfg.d/zz-anybot-slim \
+ && apt-get update && apt-get install -y --no-install-recommends \
+ tigervnc-standalone-server tigervnc-tools xdotool x11-utils x11-xserver-utils imagemagick xterm \
+ dbus-x11 xfconf xfce4-panel xfwm4 xfdesktop4 xfce4-settings xfce4-terminal \
+ thunar tumbler mousepad ristretto xdg-utils \
+ arc-theme papirus-icon-theme adwaita-icon-theme gnome-themes-extra librsvg2-common \
at-spi2-core libatk-adaptor python3-gi gir1.2-atspi-2.0 libglib2.0-bin gsettings-desktop-schemas dconf-gsettings-backend \
- novnc python3-websockify chromium fonts-noto-cjk fonts-noto-color-emoji \
+ novnc python3-websockify chromium chromium-l10n fonts-dejavu-core fonts-liberation fonts-noto-cjk fonts-noto-color-emoji \
+ locales tzdata \
ca-certificates curl wget git jq unzip zip less nano vim-tiny procps psmisc \
- python3 python3-pip python3-venv nodejs npm sudo tini dbus-x11 xclip poppler-utils \
+ python3 python3-pip python3-venv nodejs npm sudo tini xclip poppler-utils \
+ && echo "zh_TW.UTF-8 UTF-8" >> /etc/locale.gen && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && locale-gen \
+ && ln -sf /usr/share/zoneinfo/Asia/Taipei /etc/localtime && echo "Asia/Taipei" > /etc/timezone \
+ && rm -rf /usr/share/icons/ePapirus /usr/share/icons/ePapirus-Dark /usr/share/icons/Papirus-Light \
+ && test -e /usr/share/icons/Papirus-Dark/48x48/apps/web-browser.svg \
+ && test -d /usr/share/themes/Arc-Dark/xfwm4 \
+ && test -f /usr/share/locale/zh_TW/LC_MESSAGES/xfce4-panel.mo \
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
&& useradd -m -s /bin/bash bot && echo 'bot ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/bot \
&& ln -sf /usr/share/novnc/vnc.html /usr/share/novnc/index.html
+# jf open 粉圓 (OFL) as the desktop's font, pinned like LazyBoy2's.
+RUN mkdir -p /usr/share/fonts/truetype/huninn \
+ && curl -fsSL https://github.com/justfont/open-huninn-font/releases/download/v2.1/jf-openhuninn-2.1.ttf \
+ -o /usr/share/fonts/truetype/huninn/jf-openhuninn-2.1.ttf \
+ && echo '9d5bf4932d31fe94c18cd8cfddc98bc1b14ce10f4e354c682179db290a99c825 /usr/share/fonts/truetype/huninn/jf-openhuninn-2.1.ttf' | sha256sum -c \
+ && fc-cache -f
COPY start.sh /usr/local/bin/anybot-box-start
COPY a11y /usr/local/bin/anybot-a11y
COPY browser /usr/local/bin/anybot-browser
COPY screen /usr/local/bin/anybot-screen
-COPY fluxbox-init /etc/anybot/fluxbox-init
-COPY overlay /etc/anybot/overlay
+COPY terminal /usr/local/bin/anybot-terminal
COPY Xresources /etc/anybot/Xresources
-COPY menu /etc/anybot/menu
-RUN chmod +x /usr/local/bin/anybot-box-start /usr/local/bin/anybot-a11y /usr/local/bin/anybot-browser /usr/local/bin/anybot-screen \
+COPY welcome.html /usr/share/anybot/welcome.html
+COPY xfce/wallpaper.svg /usr/share/anybot/wallpaper.svg
+COPY xfce/xfce4-panel.xml /usr/share/anybot/xfce-skel/xfce4-panel.xml
+COPY xfce/xfwm4.xml /usr/share/anybot/xfce-skel/xfwm4.xml
+COPY xfce/xfce4-desktop.xml /usr/share/anybot/xfce-skel/xfce4-desktop.xml
+COPY xfce/helpers.rc /etc/xdg/xfce4/helpers.rc
+COPY xfce/mimeapps.list /etc/xdg/mimeapps.list
+COPY xfce/menu.xml /etc/xdg/menus/xfce-applications.menu
+COPY xfce/xfce4-panel-lock.xml /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml
+COPY xfce/helper-browser.desktop /usr/share/xfce4/helpers/anybot-browser.desktop
+COPY xfce/helper-terminal.desktop /usr/share/xfce4/helpers/anybot-terminal.desktop
+COPY xfce/browser.desktop /usr/share/applications/anybot-browser.desktop
+COPY xfce/terminal.desktop /usr/share/applications/anybot-terminal.desktop
+COPY fonts.conf /etc/fonts/conf.d/99-anybot-cjk.conf
+COPY gtk3-settings.ini /etc/gtk-3.0/settings.ini
+COPY licenses/huninn-OFL.txt /usr/share/licenses/huninn/OFL.txt
+RUN chmod +x /usr/local/bin/anybot-box-start /usr/local/bin/anybot-a11y /usr/local/bin/anybot-browser /usr/local/bin/anybot-screen /usr/local/bin/anybot-terminal \
+ # The menu shows 瀏覽器 and 終端機 once each: anybot-browser is the one way to start Chromium
+ # (the same profile and DevTools port as the browser tools), anybot-terminal the terminal.
+ # (Into [Desktop Entry]: chromium.desktop ends with its actions, where an appended line went.)
+ && for f in chromium xfce4-terminal debian-xterm debian-uxterm xterm uxterm; do \
+ if [ -f "/usr/share/applications/$f.desktop" ]; then sed -i '/^\[Desktop Entry\]/a NoDisplay=true' "/usr/share/applications/$f.desktop"; fi; \
+ done \
+ # The menu's names in plain words (檔案管理員, not 「Thunar 檔案管理員」); the build stops if a
+ # new Debian says them differently.
+ && sed -i 's/^Name\[zh_TW\]=Thunar 檔案管理員$/Name[zh_TW]=檔案管理員/' /usr/share/applications/thunar.desktop \
+ && sed -i 's/^Name\[zh_TW\]=Mousepad$/Name[zh_TW]=文字編輯器/' /usr/share/applications/org.xfce.mousepad.desktop \
+ && sed -i 's/^Name\[zh_TW\]=Ristretto 影像檢視器$/Name[zh_TW]=影像檢視器/' /usr/share/applications/org.xfce.ristretto.desktop \
+ && grep -qx 'Name\[zh_TW\]=檔案管理員' /usr/share/applications/thunar.desktop \
+ && grep -qx 'Name\[zh_TW\]=文字編輯器' /usr/share/applications/org.xfce.mousepad.desktop \
+ && grep -qx 'Name\[zh_TW\]=影像檢視器' /usr/share/applications/org.xfce.ristretto.desktop \
+ # (Which program opens what: /etc/xdg/mimeapps.list; the browser's file says it takes web pages and PDFs.)
+ && { ! command -v update-desktop-database >/dev/null || update-desktop-database -q /usr/share/applications; } \
# Chromium has no sandbox inside a plain container (no user namespaces); the box itself is
# the sandbox. Under gVisor (容器隔離=runsc) the box has its own virtualized kernel and
# Chromium's sandbox works: AnyBot then starts the box with ANYBOT_BOX_SANDBOX=1 and the
@@ -38,8 +103,10 @@ RUN chmod +x /usr/local/bin/anybot-box-start /usr/local/bin/anybot-a11y /usr/loc
# Accessibility on for every app, including those started over `docker exec`.
# gail too: GTK 2 apps (lxappearance, PCManFM, many older tools) offer no controls to AT-SPI
# without it — no numbers at all, only a picture to guess at. GTK 3 apps ignore it.
-ENV DISPLAY=:1 SCREEN_SIZE=1280x800x24 GTK_MODULES=gail:atk-bridge GTK_A11Y=atspi GNOME_ACCESSIBILITY=1 NO_AT_BRIDGE=0
+# Traditional Chinese for every program (menus, Chromium, a terminal's messages); LC_ALL stays
+# unset, so one command can still ask for LANG=C.
+ENV LANG=zh_TW.UTF-8 LANGUAGE=zh_TW:zh:en DISPLAY=:1 SCREEN_SIZE=1280x800x24 XDG_CURRENT_DESKTOP=XFCE GTK_MODULES=gail:atk-bridge GTK_A11Y=atspi GNOME_ACCESSIBILITY=1 NO_AT_BRIDGE=0
EXPOSE 6080
-LABEL anybot.box.version="11"
+LABEL anybot.box.version="12"
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["/usr/local/bin/anybot-box-start"]
diff --git a/box/a11y b/box/a11y
index c098c9f..d5ee37a 100644
--- a/box/a11y
+++ b/box/a11y
@@ -25,8 +25,9 @@ ACTIVE = {
# Listed when they carry words (headings, labels, cells...).
NAMED = {"heading", "label", "static", "text", "image", "table cell", "column header", "row header", "icon",
"tool tip", "alert", "dialog", "paragraph"}
-# The desktop's own parts are visible in the picture; the list is for the windows worked in.
-SKIP_APPS = {"fluxbox", "a11y", "python3", "xterm-wrapper"}
+# The desktop's own parts (the panel, the wallpaper, the window manager) are visible in the
+# picture; the list is for the windows worked in.
+SKIP_APPS = {"xfce4-panel", "xfdesktop", "xfwm4", "wrapper-2.0", "fluxbox", "a11y", "python3", "xterm-wrapper"}
def stacked_windows():
diff --git a/box/browser b/box/browser
index 245514d..9401b7e 100644
--- a/box/browser
+++ b/box/browser
@@ -6,6 +6,8 @@
set -euo pipefail
export DISPLAY="${DISPLAY:-:1}" HOME=/home/bot
export GTK_MODULES=atk-bridge GTK_A11Y=atspi GNOME_ACCESSIBILITY=1 NO_AT_BRIDGE=0
+# Chinese menus and pages asked for in Chinese first (as on LazyBoy2's box).
+export LANG="${LANG:-zh_TW.UTF-8}" LANGUAGE="${LANGUAGE:-zh_TW:zh:en}"
if [[ -z "${DBUS_SESSION_BUS_ADDRESS:-}" && -r /tmp/anybot-dbus.env ]]; then
# shellcheck disable=SC1091
source /tmp/anybot-dbus.env
@@ -64,7 +66,7 @@ FLAGS=("${SANDBOX[@]}" --user-data-dir="$PROFILE" --remote-debugging-address=127
--remote-allow-origins=http://127.0.0.1 --force-renderer-accessibility --disable-blink-features=AutomationControlled
--disable-dev-shm-usage --disable-gpu --use-angle=swiftshader --enable-unsafe-swiftshader --password-store=basic
--no-first-run --no-default-browser-check --disable-session-crashed-bubble --hide-crash-restore-bubble
- --disable-features=TranslateUI --start-maximized)
+ --disable-features=TranslateUI --start-maximized --lang=zh-TW --accept-lang=zh-TW,zh,en-US,en)
# Two starts in the same second (the bot and the person) would both find no browser and fight
# over the profile ("in use"): one at a time until the first is listening.
exec 9>"$LOCK"
diff --git a/box/fluxbox-init b/box/fluxbox-init
deleted file mode 100644
index a9e9be8..0000000
--- a/box/fluxbox-init
+++ /dev/null
@@ -1,9 +0,0 @@
-session.screen0.toolbar.visible: true
-session.screen0.toolbar.placement: BottomCenter
-session.screen0.toolbar.widthPercent: 100
-session.screen0.workspaces: 1
-session.screen0.workspaceNames: Bot 的電腦
-session.screen0.defaultDeco: NORMAL
-session.styleOverlay: ~/.fluxbox/overlay
-session.screen0.allowRemoteActions: true
-session.screen0.rootCommand: xsetroot -solid '#2b2f36'
diff --git a/box/fonts.conf b/box/fonts.conf
new file mode 100644
index 0000000..b1faef7
--- /dev/null
+++ b/box/fonts.conf
@@ -0,0 +1,41 @@
+
+
+
+
+
+ 粉圓
+ jf open 粉圓 2.1
+
+
+ jf open 粉圓
+ jf open 粉圓 2.1
+
+
+ Huninn
+ jf open 粉圓 2.1
+
+
+
+ sans-serif
+
+ jf open 粉圓 2.1
+
+
+
+ zh
+ sans-serif
+
+ jf open 粉圓 2.1
+
+
+
+
+ monospace
+
+ Noto Sans Mono CJK TC
+
+
+ DejaVu Sans Mono
+
+
+
diff --git a/box/gtk3-settings.ini b/box/gtk3-settings.ini
new file mode 100644
index 0000000..23cc34c
--- /dev/null
+++ b/box/gtk3-settings.ini
@@ -0,0 +1,7 @@
+[Settings]
+gtk-font-name=jf open 粉圓 2.1 12
+gtk-icon-theme-name=Papirus-Dark
+gtk-theme-name=Arc-Dark
+gtk-application-prefer-dark-theme=1
+gtk-dialogs-use-header=true
+gtk-menu-images=true
diff --git a/box/licenses/huninn-OFL.txt b/box/licenses/huninn-OFL.txt
new file mode 100644
index 0000000..7058b6a
--- /dev/null
+++ b/box/licenses/huninn-OFL.txt
@@ -0,0 +1,101 @@
+[Kosugi Maru]
+Copyright (c) 2010 MOTOYA CO.,LTD.
+
+[Varela Round]
+Copyright (c) 2011-2016 The Varela Round Project Authors (https://github.com/alefalefalef/Varela-Round-Hebrew/), with Reserved Font Names 'Varela' and 'Varela Round'.
+
+[jf open huninn]
+Copyright (c) 2020-2024 The jf open huninn font is redistributed by justfont Co., LTD., with Reserved Font Names 'open huninn' and 'huninn'. under SIL Open Font License. The Hanzi part of this project was derived from Kosugi Maru under Apache-2.0 (https://www.apache.org/licenses/LICENSE-2.0).
+
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/box/menu b/box/menu
deleted file mode 100644
index 67b915d..0000000
--- a/box/menu
+++ /dev/null
@@ -1,7 +0,0 @@
-[begin] (Bot 的電腦)
- [exec] (瀏覽器 Chromium) {anybot-browser}
- [exec] (終端機) {xterm}
- [separator]
- [workspaces] (視窗)
- [restart] (重新整理桌面)
-[end]
diff --git a/box/overlay b/box/overlay
deleted file mode 100644
index 71e41b5..0000000
--- a/box/overlay
+++ /dev/null
@@ -1,2 +0,0 @@
-background: none
-*.font: Noto Sans CJK TC-10
diff --git a/box/screen b/box/screen
index c9c4105..aea5962 100755
--- a/box/screen
+++ b/box/screen
@@ -27,13 +27,13 @@ mkdir -p "$DIR" 2>/dev/null; chmod 1777 "$DIR" 2>/dev/null
TOKENS=/tmp/anybot-vnc-tokens
key_ok() { [[ "$1" =~ ^[A-Za-z0-9_-]{1,48}$ ]]; }
-# The bot user's side of the desktop (fluxbox, the buses): as is when we are the bot user.
+# The bot user's side of the desktop (XFCE, the buses): as is when we are the bot user.
as_bot() { if [ "$(id -u)" = 0 ]; then su bot -c "$1"; else sh -c "$1"; fi; }
token_set() { { grep -v "^$1: " "$TOKENS" 2>/dev/null; [ -n "${2:-}" ] && echo "$1: localhost:$2"; } > "$TOKENS.new"; mv -f "$TOKENS.new" "$TOKENS"; }
alive() { [ -n "${1:-}" ] && kill -0 "$1" 2>/dev/null; }
-# The screen's processes (Xtigervnc, its dbus, fluxbox, the accessibility bus, the browser), killed
-# youngest first.
+# The screen's processes (Xtigervnc, its dbus, the accessibility bus, the desktop, the browser),
+# killed youngest first.
close() {
local d=$DIR/$1
[ -d "$d" ] || return 0
@@ -106,10 +106,18 @@ up() {
[ -x "$c" ] && { as_bot "DISPLAY=:$disp DBUS_SESSION_BUS_ADDRESS=$bus setsid $c >/dev/null 2>&1 & echo \$!" 8>&- >> "$d/pids"; break; }
done
as_bot "DISPLAY=:$disp xrdb -nocpp -merge /home/bot/.Xresources" 2>/dev/null
- as_bot "DISPLAY=:$disp DBUS_SESSION_BUS_ADDRESS=$bus setsid fluxbox >/dev/null 2>&1 & echo \$!" 8>&- >> "$d/pids"
+ xsetroot -display ":$disp" -solid '#2f343f'
+ # The same desktop as the shared screen (start.sh): window manager, wallpaper, panel. Their
+ # settings are the shared screen's files, read by this bus's own xfconfd. (A simple command each,
+ # so $! is the program itself and close() can stop it; the panel's is the loop that brings it
+ # back when it is closed, as on the shared screen, and ends with the screen.)
+ local x="DISPLAY=:$disp DBUS_SESSION_BUS_ADDRESS=$bus setsid"
+ as_bot "$x xfwm4 --compositor=off --sm-client-disable >/dev/null 2>&1 & echo \$!" 8>&- >> "$d/pids"
+ sleep 0.3
+ as_bot "$x xfdesktop --disable-wm-check --sm-client-disable >/dev/null 2>&1 & echo \$!" 8>&- >> "$d/pids"
+ as_bot "$x sh -c 'while xdpyinfo >/dev/null 2>&1; do xfce4-panel --disable-wm-check --sm-client-disable; sleep 1; done' >/dev/null 2>&1 & echo \$!" 8>&- >> "$d/pids"
# Copy and paste with the person's computer (as on the shared screen: start.sh).
as_bot "DISPLAY=:$disp setsid vncconfig -nowin >/dev/null 2>&1 & echo \$!" 8>&- >> "$d/pids"
- xsetroot -display ":$disp" -solid '#2b2f36'
{
echo "DISPLAY=:$disp"
echo "DBUS_SESSION_BUS_ADDRESS=$bus"
diff --git a/box/start.sh b/box/start.sh
index 6e46aa8..ccd0e64 100644
--- a/box/start.sh
+++ b/box/start.sh
@@ -1,28 +1,40 @@
#!/bin/bash
-# Boots the desktop: X server, window manager, VNC and the noVNC web viewer.
+# Boots the desktop: X server, a minimal XFCE (window manager, desktop, panel; no session
+# manager), VNC, the noVNC web viewer and the browser.
set -u
-mkdir -p /home/bot/.fluxbox /home/bot/Desktop && cp -n /etc/anybot/fluxbox-init /home/bot/.fluxbox/init 2>/dev/null
-cp -n /etc/anybot/overlay /home/bot/.fluxbox/overlay 2>/dev/null
+mkdir -p /home/bot/Desktop /home/bot/Downloads
+# 下載 in the sidebar of 檔案管理員 and of every file window (a web page's 上傳檔案): what the bots
+# download is there (/home/bot/Downloads).
+BM=/home/bot/.config/gtk-3.0/bookmarks
+mkdir -p "${BM%/*}"
+grep -q '^file:///home/bot/Downloads' "$BM" 2>/dev/null || printf 'file:///home/bot/Downloads 下載\n' >> "$BM"
cp -n /etc/anybot/Xresources /home/bot/.Xresources 2>/dev/null
-cp /etc/anybot/menu /home/bot/.fluxbox/menu 2>/dev/null
+# XFCE's settings come from the image on every boot (after LazyBoy2's box), so the desktop
+# always looks the way the image says; the files and the browser's logins are what last.
+XML=/home/bot/.config/xfce4/xfconf/xfce-perchannel-xml
+mkdir -p "$XML" /home/bot/.config/xfce4/panel
+for f in xfce4-panel.xml xfwm4.xml xfce4-desktop.xml; do cp -f "/usr/share/anybot/xfce-skel/$f" "$XML/$f"; done
+cp -f /etc/xdg/xfce4/helpers.rc /home/bot/.config/xfce4/helpers.rc
# GTK's dialogs (a web page's 上傳檔案 in Chromium, e.g. Threads' 加入相片) with 取消 and 開啟 in a
# bar at the top, as on GNOME. Without GNOME's settings service GTK put them at the bottom of a
# file window taller than the screen, under the taskbar: a picture could be found but never sent.
+# (/etc/gtk-3.0/settings.ini says so too; a home from an older box has its own file.)
GTKINI=/home/bot/.config/gtk-3.0/settings.ini
mkdir -p "${GTKINI%/*}"
grep -q '^\[Settings\]' "$GTKINI" 2>/dev/null || printf '[Settings]\n' >> "$GTKINI"
grep -q '^gtk-dialogs-use-header' "$GTKINI" || sed -i '/^\[Settings\]/a gtk-dialogs-use-header=true' "$GTKINI"
-chown -R bot:bot /home/bot
rm -f /tmp/.X1-lock /tmp/.X11-unix/X1
# One TigerVNC server is the screen and the VNC server (was Xvfb + x11vnc, which polls the
# screen for changes). VNC only on 127.0.0.1 inside the box, with the box's VNC password when the
# app gave one (VNC_PASSWORD), as before.
GEOM="${SCREEN_SIZE%x*}"
+SW="${GEOM%x*}"; SH="${GEOM#*x}"
+# The panel along the bottom, the screen's whole width.
+sed -i "s/p=8;x=[0-9]*;y=[0-9]*/p=8;x=$((SW / 2));y=$((SH - 18))/" "$XML/xfce4-panel.xml"
if [ -n "${VNC_PASSWORD:-}" ]; then
mkdir -p /home/bot/.vnc
printf '%s\n' "$VNC_PASSWORD" | vncpasswd -f > /home/bot/.vnc/passwd && chmod 600 /home/bot/.vnc/passwd
# (The bot user opens the bots' own screens with the same password: anybot-screen.)
- chown bot:bot /home/bot/.vnc /home/bot/.vnc/passwd
VNC_SEC="-SecurityTypes VncAuth -rfbauth /home/bot/.vnc/passwd"
else
VNC_SEC="-SecurityTypes None"
@@ -32,6 +44,11 @@ Xtigervnc :1 -geometry "$GEOM" -depth 24 -rfbport 5900 -localhost $VNC_SEC -Alwa
>/tmp/xvnc.log 2>&1 &
XVFB_PID=$!
for i in $(seq 1 50); do xdpyinfo -display :1 >/dev/null 2>&1 && break; sleep 0.1; done
+xsetroot -display :1 -solid '#2f343f'
+# The wallpaper is kept under the screen's output name (TigerVNC's VNC-0).
+OUT=$(xrandr --display :1 --query 2>/dev/null | awk '/ connected/ {print $1; exit}')
+sed -i "s/@OUTPUT@/${OUT:-VNC-0}/" "$XML/xfce4-desktop.xml"
+chown -R bot:bot /home/bot
# The session bus and the accessibility registry; tools started later over `docker exec`
# (anybot-a11y, anybot-browser) join this bus through /tmp/anybot-dbus.env.
su bot -c 'cd /home/bot && dbus-launch --sh-syntax > /tmp/anybot-dbus.sh' && . /tmp/anybot-dbus.sh
@@ -39,23 +56,31 @@ printf 'DBUS_SESSION_BUS_ADDRESS=%s\n' "$DBUS_SESSION_BUS_ADDRESS" > /tmp/anybot
chown bot:bot /tmp/anybot-dbus.env /tmp/anybot-dbus.sh 2>/dev/null || true
chmod 600 /tmp/anybot-dbus.env /tmp/anybot-dbus.sh
export DBUS_SESSION_BUS_ADDRESS
+AS_BOT="cd /home/bot && DISPLAY=:1 DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS"
for c in /usr/libexec/at-spi-bus-launcher /usr/lib/at-spi2-core/at-spi-bus-launcher; do
- [ -x "$c" ] && { su bot -c "DISPLAY=:1 DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS $c --launch-immediately >/tmp/atspi-bus.log 2>&1 &"; break; }
+ [ -x "$c" ] && { su bot -c "$AS_BOT $c --launch-immediately >/tmp/atspi-bus.log 2>&1 &"; break; }
done
for c in /usr/libexec/at-spi2-registryd /usr/lib/at-spi2-core/at-spi2-registryd; do
- [ -x "$c" ] && { su bot -c "DISPLAY=:1 DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS $c >/tmp/atspi-registry.log 2>&1 &"; break; }
+ [ -x "$c" ] && { su bot -c "$AS_BOT $c >/tmp/atspi-registry.log 2>&1 &"; break; }
done
-su bot -c "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS gsettings set org.gnome.desktop.interface toolkit-accessibility true" 2>/dev/null || true
-# The file window opens smaller than the screen, whatever size it was left at.
-SW="${GEOM%x*}"; SH="${GEOM#*x}"
-su bot -c "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS gsettings set org.gtk.Settings.FileChooser window-size '($((SW * 7 / 10)), $((SH * 3 / 4)))'" 2>/dev/null || true
-su bot -c "DISPLAY=:1 DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS xrdb -nocpp -merge /home/bot/.Xresources"
-su bot -c "DISPLAY=:1 DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS fluxbox >/tmp/fluxbox.log 2>&1 &"
+su bot -c "$AS_BOT gsettings set org.gnome.desktop.interface toolkit-accessibility true" 2>/dev/null || true
+# The file window opens smaller than the screen, whatever size it was left at. (GTK takes the
+# saved size only with a saved place too; without one it sized the window from the font, and with
+# 粉圓 12 that was 1342×1029: 開啟 off the right edge of the screen.)
+su bot -c "$AS_BOT gsettings set org.gtk.Settings.FileChooser window-size '($((SW * 7 / 10)), $((SH * 3 / 4)))'" 2>/dev/null || true
+su bot -c "$AS_BOT gsettings set org.gtk.Settings.FileChooser window-position '($((SW * 15 / 100)), $((SH / 8)))'" 2>/dev/null || true
+su bot -c "$AS_BOT xrdb -nocpp -merge /home/bot/.Xresources"
+# The desktop: the window manager first, then the wallpaper and the panel (their settings come
+# from xfconfd, which the session bus starts on the first ask).
+su bot -c "$AS_BOT xfwm4 --compositor=off --sm-client-disable >/tmp/xfwm4.log 2>&1 &"
+sleep 0.3
+su bot -c "$AS_BOT xfdesktop --disable-wm-check --sm-client-disable >/tmp/xfdesktop.log 2>&1 &"
+# The panel comes back when it is closed: its 面板 › 登出 › 結束 quits only the panel, and nothing
+# brought it back until the next boot. (Its own restart re-runs it in place.)
+su bot -c "$AS_BOT sh -c 'while xdpyinfo >/dev/null 2>&1; do xfce4-panel --disable-wm-check --sm-client-disable; sleep 1; done' >/tmp/xfce4-panel.log 2>&1 &"
# Copy and paste between the person's computer and this one: Xvnc hands the viewer's clipboard to
# the X selections (and back) only while vncconfig runs (after LazyBoy2's box).
su bot -c "DISPLAY=:1 vncconfig -nowin >/tmp/vncconfig.log 2>&1 &"
-(sleep 1.5; xsetroot -display :1 -solid '#2b2f36') &
-xsetroot -display :1 -solid '#2b2f36'
# One web viewer for every screen: the shared one is "main"; anybot-screen adds each bot's own
# (每個 Bot 一個螢幕). A viewer picks one with ?path=websockify%3Ftoken%3D.
rm -rf /tmp/anybot-screens; mkdir -p /tmp/anybot-screens && chmod 1777 /tmp/anybot-screens
@@ -64,6 +89,13 @@ echo "main: localhost:5900" > /tmp/anybot-vnc-tokens && chown bot:bot /tmp/anybo
# only watching a still screen.)
websockify --heartbeat=30 --web /usr/share/novnc --token-plugin TokenFile --token-source /tmp/anybot-vnc-tokens 6080 >/tmp/novnc.log 2>&1 &
WEBSOCKIFY_PID=$!
+# The browser is open on the shared screen from the start, as on LazyBoy2's box: a profile's very
+# first boot shows what this computer is for, later ones an empty page.
+if [ -d /home/bot/.config/anybot-profile/Default ]; then
+ su bot -c "$AS_BOT anybot-browser >/dev/null 2>&1 &"
+else
+ su bot -c "$AS_BOT anybot-browser file:///usr/share/anybot/welcome.html >/dev/null 2>&1 &"
+fi
# Say ready only once the viewer's port listens: the app opens noVNC on this flag, and a too
# early file meant the first viewer load 404'd.
(
@@ -73,9 +105,28 @@ WEBSOCKIFY_PID=$!
done
echo "anybot-box ready" > /tmp/anybot-box.ready
) &
+# `docker stop`: the browsers close the normal way first, so a login made a moment ago is on
+# disk (killed outright, Chromium can lose its last cookies). Only the main processes, not their
+# renderers.
+stop_browsers() {
+ local pids="" p
+ for p in $(pgrep -u bot -x chromium); do
+ tr '\0' '\n' < "/proc/$p/cmdline" 2>/dev/null | grep -q '^--type=' || pids="$pids $p"
+ done
+ [ -n "$pids" ] || return 0
+ kill -TERM $pids 2>/dev/null
+ for _ in $(seq 1 50); do
+ local alive=0
+ for p in $pids; do kill -0 "$p" 2>/dev/null && alive=1; done
+ [ "$alive" = 0 ] && break
+ sleep 0.1
+ done
+}
+trap 'stop_browsers; kill $WEBSOCKIFY_PID $XVFB_PID 2>/dev/null; exit 0' TERM INT
# When the desktop's heart stops, the container ends too (it used to sit there as Running
# with a dead X server, and every screen action failed forever).
wait $XVFB_PID
kill $WEBSOCKIFY_PID 2>/dev/null
-pkill -u bot fluxbox 2>/dev/null
+pkill -u bot xfce4-panel 2>/dev/null
+pkill -u bot xfwm4 2>/dev/null
exit 1
diff --git a/box/terminal b/box/terminal
new file mode 100644
index 0000000..73ba0dc
--- /dev/null
+++ b/box/terminal
@@ -0,0 +1,15 @@
+#!/bin/bash
+# The box's terminal (after LazyBoy2's box-terminal): xfce4-terminal, one process per window
+# (--disable-server), on the desktop's session bus. 工作列和選單的「終端機」, and what the bots
+# open as 終端機 (computer_use_open_app).
+export DISPLAY="${DISPLAY:-:1}" HOME=/home/bot
+export TERM="${TERM:-xterm-256color}" COLORTERM="${COLORTERM:-truecolor}"
+if [[ -z "${DBUS_SESSION_BUS_ADDRESS:-}" && -r /tmp/anybot-dbus.env ]]; then
+ # shellcheck disable=SC1091
+ source /tmp/anybot-dbus.env
+ export DBUS_SESSION_BUS_ADDRESS
+fi
+# From the panel or `docker exec` (at /): the home folder. From 檔案管理員's 「在此開啟終端機」:
+# the folder that was open there.
+[[ "$PWD" = / || ! -d "$PWD" ]] && { cd /home/bot 2>/dev/null || cd /; }
+exec xfce4-terminal --disable-server --geometry=100x28+40+40 --title=終端機 --working-directory="$PWD" "$@"
diff --git a/box/welcome.html b/box/welcome.html
new file mode 100644
index 0000000..2cec29e
--- /dev/null
+++ b/box/welcome.html
@@ -0,0 +1,17 @@
+
+
+
+
+ Bot 的電腦
+
+
+
+