Skip to content

Commit

Permalink
fix(lightdm): install raspberrypi-ui-mods instead of lightdm to activ…
Browse files Browse the repository at this point in the history
…ate wayland and enable rpi-connect screen sharing
  • Loading branch information
sassanh committed Sep 1, 2024
1 parent 0e7ad6f commit bc12ab9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions tests/monkeypatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def _monkeypatch(monkeypatch: pytest.MonkeyPatch) -> None:
from fake import Fake

import ubo_app.constants
import ubo_app.utils.monitor_unit
import ubo_app.utils.serializer

tracemalloc.start()
Expand All @@ -272,6 +273,7 @@ def _monkeypatch(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(ubo_app.constants, 'STORE_GRACE_PERIOD', 0.1)
monkeypatch.setattr(ubo_app.constants, 'NOTIFICATIONS_FLASH_TIME', 1000)
monkeypatch.setattr(ubo_app.utils.serializer, 'add_type_field', lambda _, obj: obj)
monkeypatch.setattr(ubo_app.utils.monitor_unit, 'monitor_unit', Fake())

sys.modules['ubo_app.utils.secrets'] = Fake(
_Fake__props={'read_secret': lambda _: None},
Expand Down
2 changes: 1 addition & 1 deletion ubo_app/services/050-lightdm/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
38 changes: 31 additions & 7 deletions ubo_app/system/system_manager/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,47 @@

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 = [
'lightdm',
'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'

0 comments on commit bc12ab9

Please sign in to comment.