From d6a88c431e8374d711972c1c9eb2d41517177adc Mon Sep 17 00:00:00 2001 From: Andrei Gherzan <andrei.gherzan@huawei.com> Date: Tue, 9 Mar 2021 11:12:01 +0000 Subject: [PATCH] weston-init: Add support for a dynamic .ini configuration This creates a mechanism to generate a dynamic weston.ini configuration based on build variables. The entire mechanism is enabled using the WESTON_DYNAMIC_INI variable (enabled when set to 1). The default path for the weston.ini configuration is set in WESTON_INI_PATH as "etc/xdg/weston/weston.ini". WESTON_INI_NO_TOOLBAR, when set to 1, disables the weston toolbar. Signed-off-by: Andrei Gherzan <andrei.gherzan@huawei.com> --- .../wayland/weston-init.bbappend | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 meta-ohos-core/recipes-graphics/wayland/weston-init.bbappend diff --git a/meta-ohos-core/recipes-graphics/wayland/weston-init.bbappend b/meta-ohos-core/recipes-graphics/wayland/weston-init.bbappend new file mode 100644 index 00000000..c98e752c --- /dev/null +++ b/meta-ohos-core/recipes-graphics/wayland/weston-init.bbappend @@ -0,0 +1,36 @@ +WESTON_DYNAMIC_INI ?= "0" +WESTON_INI_PATH ?= "etc/xdg/weston/weston.ini" + +WESTON_INI_NO_TOOLBAR ?= "0" + +python generate_dynamic_ini() { + import configparser + + # Avoid everything if dynamic configuration is not requested . + do = d.getVar('WESTON_DYNAMIC_INI', True) + if do != '1': + bb.note("No dynamic weston.ini configuration requested.") + return + bb.note("Dynamic weston.ini configuration requested.") + + config = configparser.ConfigParser() + ini_path = os.path.join(d.getVar('D', True), d.getVar('WESTON_INI_PATH', True)) + + # Prepopulate an existing configuration. + if os.path.exists(ini_path): + if not os.path.isfile(ini_path): + bb.fatal("weston.ini already exists and it is not a regular file") + config.read(ini_path) + + # Handle no toolbar configuration. + if d.getVar('WESTON_INI_NO_TOOLBAR', True) == '1': + bb.note('Handling WESTON_INI_NO_TOOLBAR.') + if 'shell' not in config.sections(): + config.add_section('shell') + config.set('shell', 'panel-position', 'none') + + # Finally, write the configuration. Keep this at the end. + with open(ini_path, 'w') as init_path_fo: + config.write(init_path_fo, space_around_delimiters=False) +} +do_install[postfuncs] += "generate_dynamic_ini" -- GitLab