diff --git a/CHANGELOG.md b/CHANGELOG.md index 71087e47..5c0fcb0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - fix(lightdm): update the menu when installation is done - refactor(lightdm): reorder settings menu and replace "utilities" with "desktop" - feat(lightdm): show a notification when rpi-connect is started to inform user desktop should be installed for the screen sharing to work +- fix(lightdm): install raspberrypi-ui-mods instead of lightdm to activate wayland and enable rpi-connect screen sharing ## Version 0.15.11 diff --git a/ubo_app/services/050-lightdm/setup.py b/ubo_app/services/050-lightdm/setup.py index e6527677..a4489613 100644 --- a/ubo_app/services/050-lightdm/setup.py +++ b/ubo_app/services/050-lightdm/setup.py @@ -165,7 +165,7 @@ async def check_lightdm() -> None: is_active, is_enabled, is_installed = await asyncio.gather( is_unit_active('lightdm'), is_unit_enabled('lightdm'), - is_package_installed('lightdm'), + is_package_installed('raspberrypi-ui-mods'), ) dispatch( diff --git a/ubo_app/system/system_manager/package.py b/ubo_app/system/system_manager/package.py index 6694f4c3..f5f6f19b 100644 --- a/ubo_app/system/system_manager/package.py +++ b/ubo_app/system/system_manager/package.py @@ -2,6 +2,9 @@ from __future__ import annotations +import subprocess + +from ubo_app.logging import get_logger from ubo_app.utils.apt import install_package, uninstall_package PACKAGE_WHITELIST = [ @@ -9,16 +12,37 @@ 'rpi-connect', ] +logger = get_logger('system-manager') + def package_handler(action: str, package: str) -> str: """Handle package actions.""" if package not in PACKAGE_WHITELIST: return 'Package not in whitelist' - if action == 'install': - install_package(package) - return 'installed' - if action == 'uninstall': - uninstall_package(package) - return 'uninstalled' - return 'Invalid package action' + try: + if action == 'install': + if package == 'lightdm': + install_package('raspberrypi-ui-mods', force=True) + subprocess.run( # noqa: S603 + [ + '/usr/bin/env', + 'sed', + '-i', + '/etc/lightdm/lightdm.conf', + '-e', + 's|#\\?autologin-user=.*|autologin-user=ubo|', + ], + check=False, + ) + else: + install_package(package) + return 'installed' + if action == 'uninstall': + uninstall_package(package) + return 'uninstalled' + except Exception: + logger.exception('Failed to handle package action') + return 'error' + else: + return 'Invalid package action'