Agent Zero AI framework
Polish Agent Zero Desktop defaults
Alessandroe63173d812de
diff --git a/plugins/_office/helpers/libreoffice_desktop.py b/plugins/_office/helpers/libreoffice_desktop.pyindex 28b458a39..fba586a34 100644--- a/plugins/_office/helpers/libreoffice_desktop.py+++ b/plugins/_office/helpers/libreoffice_desktop.py@@ -44,6 +44,10 @@ HIDDEN_XPRA_DESKTOP_ENTRIES = ("xpra-shadow.desktop","xpra-start.desktop",)+HIDDEN_XFCE_MENU_ENTRIES = (+ ("exo-mail-reader.desktop", "Mail Reader"),+ ("exo-web-browser.desktop", "Web Browser"),+)DESKTOP_README_SOURCE = Path(__file__).resolve().parents[1] / "assets" / "desktop" / "README.md"DESKTOP_FOLDER_LINKS = (("Projects", ("usr", "projects")),@@ -516,6 +520,7 @@ class LibreOfficeDesktopManager:""",encoding="utf-8",)+ _write_thunar_defaults(xfce_conf_dir / "thunar.xml")helpers_rc = config_dir / "xfce4" / "helpers.rc"helpers_rc.parent.mkdir(parents=True, exist_ok=True)helpers_rc.write_text(@@ -529,6 +534,7 @@ class LibreOfficeDesktopManager:encoding="utf-8",)self._hide_xpra_desktop_entries(applications_dir)+ self._hide_xfce_menu_entries(applications_dir)base_args = (soffice,@@ -602,19 +608,11 @@ class LibreOfficeDesktopManager:def _hide_xpra_desktop_entries(self, applications_dir: Path) -> None:for filename in HIDDEN_XPRA_DESKTOP_ENTRIES:- (applications_dir / filename).write_text(- "\n".join(- [- "[Desktop Entry]",- "Type=Application",- "Name=Xpra",- "NoDisplay=true",- "Hidden=true",- "",- ],- ),- encoding="utf-8",- )+ _write_hidden_application_entry(applications_dir / filename, "Xpra")++ def _hide_xfce_menu_entries(self, applications_dir: Path) -> None:+ for filename, name in HIDDEN_XFCE_MENU_ENTRIES:+ _write_hidden_application_entry(applications_dir / filename, name)def _prepare_xfce_panel_config(self, session: DesktopSession) -> None:panel_xml = (@@ -684,6 +682,7 @@ export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"export XDG_CURRENT_DESKTOP="${XDG_CURRENT_DESKTOP:-XFCE}"mkdir -p "$HOME/Desktop" "$XDG_CONFIG_HOME" "$XDG_DATA_HOME" "$XDG_CACHE_HOME"if command -v xfconf-query >/dev/null 2>&1; then+ xfconf-query -c thunar -p /last-show-hidden -n -t bool -s true >/dev/null 2>&1 || truexfconf-query -c xfce4-desktop -p /desktop-icons/style -n -t int -s 2 >/dev/null 2>&1 || truexfconf-query -c xfce4-desktop -p /desktop-icons/file-icons/show-home -n -t bool -s false >/dev/null 2>&1 || truexfconf-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(pass+def _write_hidden_application_entry(path: Path, name: str) -> None:+ path.parent.mkdir(parents=True, exist_ok=True)+ path.write_text(+ "\n".join(+ [+ "[Desktop Entry]",+ "Type=Application",+ f"Name={name}",+ "NoDisplay=true",+ "Hidden=true",+ "",+ ],+ ),+ encoding="utf-8",+ )+++def _write_thunar_defaults(path: Path) -> None:+ root = _read_xfce_channel(path, "thunar")+ if _find_xfce_property(root, "last-view") is None:+ _xfce_property(root, "last-view", "string", "ThunarIconView")+ _xfce_property(root, "last-show-hidden", "bool", "true")+ _write_xfce_channel(path, root)+++def _read_xfce_channel(path: Path, channel_name: str) -> ET.Element:+ if path.exists():+ try:+ root = ET.parse(path).getroot()+ if root.tag == "channel" and root.get("name") == channel_name:+ root.set("version", root.get("version") or "1.0")+ return root+ except (ET.ParseError, OSError):+ pass+ return ET.Element("channel", {"name": channel_name, "version": "1.0"})+++def _write_xfce_channel(path: Path, root: ET.Element) -> None:+ path.parent.mkdir(parents=True, exist_ok=True)+ tree = ET.ElementTree(root)+ try:+ ET.indent(tree, space=" ")+ except AttributeError:+ pass+ tree.write(path, encoding="utf-8", xml_declaration=True)+++def _find_xfce_property(parent: ET.Element, name: str) -> ET.Element | None:+ return next((child for child in parent.findall("property") if child.get("name") == name), None)++def _install_desktop_readme(desktop_dir: Path) -> None:if not DESKTOP_README_SOURCE.exists():returndiff --git a/tests/test_office_canvas_setup.py b/tests/test_office_canvas_setup.pyindex 71c80d935..e73a5e90e 100644--- a/tests/test_office_canvas_setup.py+++ b/tests/test_office_canvas_setup.py@@ -265,6 +265,10 @@ def test_official_libreoffice_desktop_route_and_packages_are_declared():assert "metadata::xfce-exe-checksum" in desktopassert "DESKTOP_FOLDER_LINKS" in desktopassert "HIDDEN_XPRA_DESKTOP_ENTRIES" in desktop+ assert "HIDDEN_XFCE_MENU_ENTRIES" in desktop+ assert "last-show-hidden" in desktop+ assert "exo-mail-reader.desktop" in desktop+ assert "exo-web-browser.desktop" in desktopassert "libreoffice-gtk3" in installassert "libreofficekit" not in installassert "gir1.2-lokdocview" not in installdiff --git a/tests/test_office_document_store.py b/tests/test_office_document_store.pyindex 4c13d8157..2fe5d6ab6 100644--- a/tests/test_office_document_store.py+++ b/tests/test_office_document_store.py@@ -296,6 +296,28 @@ def test_markdown_session_rejects_office_binaries(office_state):manager.open(doc)+def test_thunar_defaults_preserve_existing_profile_settings(tmp_path):+ thunar_xml = tmp_path / "thunar.xml"+ thunar_xml.write_text(+ """<?xml version="1.1" encoding="UTF-8"?>+<channel name="thunar" version="1.0">+ <property name="last-view" type="string" value="ThunarDetailsView"/>+ <property name="last-window-width" type="int" value="900"/>+ <property name="last-show-hidden" type="bool" value="false"/>+</channel>+""",+ encoding="utf-8",+ )++ libreoffice_desktop._write_thunar_defaults(thunar_xml)++ root = ET.parse(thunar_xml).getroot()+ values = {child.get("name"): child.get("value") for child in root.findall("property")}+ assert values["last-view"] == "ThunarDetailsView"+ assert values["last-window-width"] == "900"+ assert values["last-show-hidden"] == "true"++def test_official_libreoffice_desktop_status_and_url_contract(tmp_path, monkeypatch):xpra_html = tmp_path / "xpra" / "www"xpra_html.mkdir(parents=True)@@ -451,6 +473,18 @@ def test_official_libreoffice_desktop_manager_opens_binary_session(office_state,assert "desktop-icons" in desktop_profile_textassert "image-path" in desktop_profile_textassert "usr/downloads" in desktop_profile_text+ thunar_profile = (+ tmp_path+ / "desktop"+ / "profiles"+ / payload["session_id"]+ / ".config"+ / "xfce4"+ / "xfconf"+ / "xfce-perchannel-xml"+ / "thunar.xml"+ ).read_text(encoding="utf-8")+ assert 'name="last-show-hidden" type="bool" value="true"' in thunar_profileuser_dirs = (tmp_path/ "desktop"@@ -501,6 +535,20 @@ def test_official_libreoffice_desktop_manager_opens_binary_session(office_state,assert '"$HOME"/Desktop/*.desktop' in profile_scriptassert "agent-zero-settings.desktop" not in profile_scriptassert "metadata::xfce-exe-checksum" in profile_script+ assert "xfconf-query -c thunar -p /last-show-hidden" in profile_script+ for filename in ("exo-mail-reader.desktop", "exo-web-browser.desktop"):+ entry = (+ tmp_path+ / "desktop"+ / "profiles"+ / payload["session_id"]+ / ".local"+ / "share"+ / "applications"+ / filename+ ).read_text(encoding="utf-8")+ assert "NoDisplay=true" in entry+ assert "Hidden=true" in entryassert manager.proxy_for_token(payload["token"]) == ("127.0.0.1", libreoffice_desktop.XPRA_PORT_BASE)assert manager.close(payload["session_id"], save_first=False)["closed"] == 0assert manager.close(payload["session_id"], save_first=False)["persistent"] is True