Site logo
Stories around the Genode Operating System RSS feed
Johannes Schlatow avatar

Adding a dynamic desktop background to Sculpt


For getting to know LVGL, I wrote a configurable desktop background for Sculpt OS that shows certain system information (e.g. clock, battery state).

LVGL (Light and Versatile Graphics Library) is a popular library for creating nice graphical user interfaces with modern looks. The idea of getting to know LVGL and making it available for app development on Genode was lingering in my head for a while. Fortunately, Josef had already spent some efforts at porting LVGL to Genode. Since I thought this would be a good opportunity to apply Goa's library-porting support, I moved his LVGL port to Goa. Moreover, as I wanted to get to know LVGL better, I decided to implement a simple application that displays system state information and that can be used as a desktop background in Sculpt OS.

This effort resulted in the pretty useful system_info package. In this article, I will demonstrate its usage. At the end of this article, I will also briefly give a few insights into the development of this LVGL application with Goa.

Installation

You can find the system_info package in my depot index so that you are able to install it on the current Sculpt OS. As a prereqüsiste, you need to make sure that you have installed an RTC (real-time clock) provider. The default Sculpt OS image contains the system_clock option for this purpose. Because my hardware clock was showing the wrong time, I recently published the system_clock_rw-pc package on my depot, which does the same job but additionally accepts a set_rtc report to set the hardware clock. Such a report is generated by the sntp_client component, which you also find on my depot.

When you have decided for an RTC provider, you can install the system_info package from my depot (GUI section). Wire up the services as shown in the screenshots below. The GUI service shall be routed to "gui (backdrop)" the RTC to the previously enabled RTC provider, the "VERSION" ROM to "model", the "platform_info" ROM to "platform information" and the remaining ROMs to "report".

The system_info package requires a GUI, an RTC and a few ROM sessions.

After installing the system_info package as shown above, it appears as a desktop background. By default, system info shows the current time, date and calendar, battery state, and the NIC router's IP addresses. It also shows the Sculpt It also shows the current Sculpt version and the used kernel as well as the IOMMU state as reported by the platform driver.

Note that the battery state is only shown when the acpi_support option is enabled.

Configuration

The system_info package is configurable. Its configuration determines what widgets are instantiated and in what order they are shown. This is the default configuration:

 config | default_timezone: CET-1CEST,M3.5.0,M10.5.0
 + vfs
 | + dir dev
 |   + log
 |   + rtc
 + libc | stdout: /dev/log | rtc: /dev/rtc

 + clock
 + calendar
 + battery | rom: acpi_support/acpi_battery

 + tabular | rom: network/state | alt: no IP found
 | + node uplink | type: domain
 | | + row | label: Uplink | attribute: ipv4
 | + node default | type: domain
 |   + row | label: Default | attribute: ipv4

 + track
 | + label | size: 32
 | + label | size: 32
 | | : Sculpt
 | + label | rom: VERSION | size: 34
 | + tabular | rom: platform_info | alt: no platform info
 |   + node | type: kernel
 |     + row | label: Kernel | attribute: name | highlight: yes

 + tabular | rom: platform/iommu  | alt: no IOMMU present
   + node | type: intel
     + row | label: IOMMU | attribute: name | highlight: yes
     + row | label: DMA Remapping | attribute: dma_remapping
     + row | label: IRQ Remapping | attribute: irq_remapping
 -

Every node (except vfs and libc) instantiates a certain widget. In the default config, you see the clock, calendar, battery as well as the tabular widgets for the NIC router and IOMMU state. The widgets are arranged automatically in columns from left to right. The available widgets and their attributes is documented in the README.Sincthe system_info package merely consists of the equally-named component,ou may easily provide your own configuration by means of an option fileseSculpt documentation).Typical examples of customisation are: changing the background colour, reordering widgets, adding/removing widgets, changing the time zone. Time zones are specified according to the POSIX TZ variable scheme. Let's add a few clock widgets with different time zones:

 config | default_timezone: CET-1CEST,M3.5.0,M10.5.0
 + vfs
 | + dir dev
 |   + log
 |   + rtc
 + libc | stdout: /dev/log | rtc: /dev/rtc

 + track
   + label | : Berlin
   + clock
   + calendar

 + track | align: top
   + label | : New York
   + clock    | timezone: UTC5
   + calendar | timezone: UTC5
 + track | align: bottom
   + label | size: 20
   | : Broken Hill,
   | : New South Wales
   + clock    | timezone: UTC-10:30
   + calendar | timezone: UTC-10:30
 -

Note, how the use of the track node arranges the widgets in three separate columns. This feature was added in the depot-archive version 2024-10-15.

Beautification

If you got used to the sticks_blue_backdrop background, you are probably going to notice the dull looks of the coloured background of system_info. Fortunately, I managed to integrate alpha-channel support, which allows combining a backdrop image with system_info. All you need to do is setting an eight-digit background colour. The last two digits of this colour determine the alpha channel from transparent (00) to completely opaque (ff). Let's try a semi-transparent background colour:

 config | background_color: #11558833
   ...
The system_info background can be combined with a backdrop image.

Development

The system_info component uses LVGL. I have added an lvgl project to my goa-projects repository in order to make a Genode port of LVGL available in form of api and src archives on my depot. Typically, LVGL is used as a static library and specifically tailored to the application. Since Goa only supports shared libraries, however, I enabled most of the features in its lv_conf.h.

In addition to the LVGL port, Josef came up with an lvgl_support library that simplifies the usage of LVGL in Genode. The support library handles the initialisation of LVGL and its interfacing to Genode's GUI session. In particular, it handles framebuffer resize events and input events. Note that the support lib is still in experimental state, especially for interactive scenarios. Nonetheless, with this support library, LVGL is easily initialised via config struct and a single init call:

 Lvgl::Config _lvgl_config { .title              = "System Info",
                             .initial_width      = 800,
                             .initial_height     = 600,
                             .allow_resize       = true,
                             .use_refresh_sync   = true,
                             .use_alpha          = true,
                             .use_keyboard       = false,
                             .use_mouse          = false,
                             .use_periodic_timer = true,
                             .periodic_ms        = 5000,
                             .resize_callback    = &_resize_callback,
                             .timer_callback     = &_timer_callback,
 };

 Lvgl::init(_env, _lvgl_config);

During the development of the system_info component with Goa, I greatly benefited from goa run, which executes the component on the host system using base-linux and an SDL-based framebuffer. By resizing the SDL window, I could conveniently test the automatic arrangement and scaling of the widgets. I also made use of the fact that Goa routes all unknown ROM sessions to an lx_fs at var/rom. This was highly comfortable as this allowed me to emulate the required system reports.

Enjoy!

Links

Goa project

https://codeberg.org/jschlatow/goa-projects/src/branch/main/apps/system_info

README

https://codeberg.org/jschlatow/goa-projects/raw/branch/main/apps/system_info/pkg/system_info/README

Edit 2024-10-15: Add <track> example.

Edit 2025-05-05: Updated instructions for Sculpt 26.04