Polish Agent Zero Desktop defaults
Show hidden files by default in Thunar-backed Desktop sessions while preserving existing file manager profile settings. Hide the default Xfce Mail Reader and Web Browser helper entries from the Applications menu through local XDG overrides, and cover the generated Desktop profile artifacts with targeted tests.
Alessandro committed
May 2, 2026 at 20:04 UTC
e63173d812de3054a965340d5f1654e995007f87
3 files changed
+115
-13
plugins/_office/helpers/libreoffice_desktop.py
+63
-13
@@ -44,6 +44,10 @@ HIDDEN_XPRA_DESKTOP_ENTRIES = (
44
"xpra-shadow.desktop",
45
"xpra-start.desktop",
46
)
47
+HIDDEN_XFCE_MENU_ENTRIES = (
48
+ ("exo-mail-reader.desktop", "Mail Reader"),
49
+ ("exo-web-browser.desktop", "Web Browser"),
50
+)
51
DESKTOP_README_SOURCE = Path(__file__).resolve().parents[1] / "assets" / "desktop" / "README.md"
52
DESKTOP_FOLDER_LINKS = (
53
("Projects", ("usr", "projects")),
@@ -516,6 +520,7 @@ class LibreOfficeDesktopManager:
520
""",
521
encoding="utf-8",
522
)
523
+ _write_thunar_defaults(xfce_conf_dir / "thunar.xml")
524
helpers_rc = config_dir / "xfce4" / "helpers.rc"
525
helpers_rc.parent.mkdir(parents=True, exist_ok=True)
526
helpers_rc.write_text(
@@ -529,6 +534,7 @@ class LibreOfficeDesktopManager:
534
encoding="utf-8",
535
)
536
self._hide_xpra_desktop_entries(applications_dir)
537
+ self._hide_xfce_menu_entries(applications_dir)
538
539
base_args = (
540
soffice,
@@ -602,19 +608,11 @@ class LibreOfficeDesktopManager:
608
609
def _hide_xpra_desktop_entries(self, applications_dir: Path) -> None:
610
for filename in HIDDEN_XPRA_DESKTOP_ENTRIES:
605
- (applications_dir / filename).write_text(
606
- "\n".join(
607
- [
608
- "[Desktop Entry]",
609
- "Type=Application",
610
- "Name=Xpra",
611
- "NoDisplay=true",
612
- "Hidden=true",
613
- "",
614
- ],
615
- ),
616
- encoding="utf-8",
617
- )
611
+ _write_hidden_application_entry(applications_dir / filename, "Xpra")
612
+
613
+ def _hide_xfce_menu_entries(self, applications_dir: Path) -> None:
614
+ for filename, name in HIDDEN_XFCE_MENU_ENTRIES:
615
+ _write_hidden_application_entry(applications_dir / filename, name)
616
617
def _prepare_xfce_panel_config(self, session: DesktopSession) -> None:
618
panel_xml = (
@@ -684,6 +682,7 @@ export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
682
export XDG_CURRENT_DESKTOP="${XDG_CURRENT_DESKTOP:-XFCE}"
683
mkdir -p "$HOME/Desktop" "$XDG_CONFIG_HOME" "$XDG_DATA_HOME" "$XDG_CACHE_HOME"
684
if command -v xfconf-query >/dev/null 2>&1; then
685
+ xfconf-query -c thunar -p /last-show-hidden -n -t bool -s true >/dev/null 2>&1 || true
686
xfconf-query -c xfce4-desktop -p /desktop-icons/style -n -t int -s 2 >/dev/null 2>&1 || true
687
xfconf-query -c xfce4-desktop -p /desktop-icons/file-icons/show-home -n -t bool -s false >/dev/null 2>&1 || true
688
xfconf-query -c xfce4-desktop -p /desktop-icons/file-icons/show-filesystem -n -t bool -s false >/dev/null 2>&1 || true
@@ -1324,6 +1323,57 @@ def _write_desktop_launcher(
1323
pass
1324
1325
1326
+def _write_hidden_application_entry(path: Path, name: str) -> None:
1327
+ path.parent.mkdir(parents=True, exist_ok=True)
1328
+ path.write_text(
1329
+ "\n".join(
1330
+ [
1331
+ "[Desktop Entry]",
1332
+ "Type=Application",
1333
+ f"Name={name}",
1334
+ "NoDisplay=true",
1335
+ "Hidden=true",
1336
+ "",
1337
+ ],
1338
+ ),
1339
+ encoding="utf-8",
1340
+ )
1341
+
1342
+
1343
+def _write_thunar_defaults(path: Path) -> None:
1344
+ root = _read_xfce_channel(path, "thunar")
1345
+ if _find_xfce_property(root, "last-view") is None:
1346
+ _xfce_property(root, "last-view", "string", "ThunarIconView")
1347
+ _xfce_property(root, "last-show-hidden", "bool", "true")
1348
+ _write_xfce_channel(path, root)
1349
+
1350
+
1351
+def _read_xfce_channel(path: Path, channel_name: str) -> ET.Element:
1352
+ if path.exists():
1353
+ try:
1354
+ root = ET.parse(path).getroot()
1355
+ if root.tag == "channel" and root.get("name") == channel_name:
1356
+ root.set("version", root.get("version") or "1.0")
1357
+ return root
1358
+ except (ET.ParseError, OSError):
1359
+ pass
1360
+ return ET.Element("channel", {"name": channel_name, "version": "1.0"})
1361
+
1362
+
1363
+def _write_xfce_channel(path: Path, root: ET.Element) -> None:
1364
+ path.parent.mkdir(parents=True, exist_ok=True)
1365
+ tree = ET.ElementTree(root)
1366
+ try:
1367
+ ET.indent(tree, space=" ")
1368
+ except AttributeError:
1369
+ pass
1370
+ tree.write(path, encoding="utf-8", xml_declaration=True)
1371
+
1372
+
1373
+def _find_xfce_property(parent: ET.Element, name: str) -> ET.Element | None:
1374
+ return next((child for child in parent.findall("property") if child.get("name") == name), None)
1375
+
1376
+
1377
def _install_desktop_readme(desktop_dir: Path) -> None:
1378
if not DESKTOP_README_SOURCE.exists():
1379
return
tests/test_office_canvas_setup.py
+4
@@ -265,6 +265,10 @@ def test_official_libreoffice_desktop_route_and_packages_are_declared():
265
assert "metadata::xfce-exe-checksum" in desktop
266
assert "DESKTOP_FOLDER_LINKS" in desktop
267
assert "HIDDEN_XPRA_DESKTOP_ENTRIES" in desktop
268
+ assert "HIDDEN_XFCE_MENU_ENTRIES" in desktop
269
+ assert "last-show-hidden" in desktop
270
+ assert "exo-mail-reader.desktop" in desktop
271
+ assert "exo-web-browser.desktop" in desktop
272
assert "libreoffice-gtk3" in install
273
assert "libreofficekit" not in install
274
assert "gir1.2-lokdocview" not in install
tests/test_office_document_store.py
+48
@@ -296,6 +296,28 @@ def test_markdown_session_rejects_office_binaries(office_state):
296
manager.open(doc)
297
298
299
+def test_thunar_defaults_preserve_existing_profile_settings(tmp_path):
300
+ thunar_xml = tmp_path / "thunar.xml"
301
+ thunar_xml.write_text(
302
+ """<?xml version="1.1" encoding="UTF-8"?>
303
+<channel name="thunar" version="1.0">
304
+ <property name="last-view" type="string" value="ThunarDetailsView"/>
305
+ <property name="last-window-width" type="int" value="900"/>
306
+ <property name="last-show-hidden" type="bool" value="false"/>
307
+</channel>
308
+""",
309
+ encoding="utf-8",
310
+ )
311
+
312
+ libreoffice_desktop._write_thunar_defaults(thunar_xml)
313
+
314
+ root = ET.parse(thunar_xml).getroot()
315
+ values = {child.get("name"): child.get("value") for child in root.findall("property")}
316
+ assert values["last-view"] == "ThunarDetailsView"
317
+ assert values["last-window-width"] == "900"
318
+ assert values["last-show-hidden"] == "true"
319
+
320
+
321
def test_official_libreoffice_desktop_status_and_url_contract(tmp_path, monkeypatch):
322
xpra_html = tmp_path / "xpra" / "www"
323
xpra_html.mkdir(parents=True)
@@ -451,6 +473,18 @@ def test_official_libreoffice_desktop_manager_opens_binary_session(office_state,
473
assert "desktop-icons" in desktop_profile_text
474
assert "image-path" in desktop_profile_text
475
assert "usr/downloads" in desktop_profile_text
476
+ thunar_profile = (
477
+ tmp_path
478
+ / "desktop"
479
+ / "profiles"
480
+ / payload["session_id"]
481
+ / ".config"
482
+ / "xfce4"
483
+ / "xfconf"
484
+ / "xfce-perchannel-xml"
485
+ / "thunar.xml"
486
+ ).read_text(encoding="utf-8")
487
+ assert 'name="last-show-hidden" type="bool" value="true"' in thunar_profile
488
user_dirs = (
489
tmp_path
490
/ "desktop"
@@ -501,6 +535,20 @@ def test_official_libreoffice_desktop_manager_opens_binary_session(office_state,
535
assert '"$HOME"/Desktop/*.desktop' in profile_script
536
assert "agent-zero-settings.desktop" not in profile_script
537
assert "metadata::xfce-exe-checksum" in profile_script
538
+ assert "xfconf-query -c thunar -p /last-show-hidden" in profile_script
539
+ for filename in ("exo-mail-reader.desktop", "exo-web-browser.desktop"):
540
+ entry = (
541
+ tmp_path
542
+ / "desktop"
543
+ / "profiles"
544
+ / payload["session_id"]
545
+ / ".local"
546
+ / "share"
547
+ / "applications"
548
+ / filename
549
+ ).read_text(encoding="utf-8")
550
+ assert "NoDisplay=true" in entry
551
+ assert "Hidden=true" in entry
552
assert manager.proxy_for_token(payload["token"]) == ("127.0.0.1", libreoffice_desktop.XPRA_PORT_BASE)
553
assert manager.close(payload["session_id"], save_first=False)["closed"] == 0
554
assert manager.close(payload["session_id"], save_first=False)["persistent"] is True