wlmaker
Loading...
Searching...
No Matches
Macros | Functions | Variables
config.c File Reference
#include "config.h"
#include <libbase/libbase.h>
#include <libbase/plist.h>
#include <stdbool.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <wlr/types/wlr_keyboard.h>
#include "../share/theme.h"
#include "default_configuration.h"
#include "default_state.h"
#include "input/cursor.h"
Include dependency graph for config.c:

Functions

static bspl_object_t * _wlmaker_plist_load (const char *name_ptr, const char *fname_ptr, const uint8_t *default_data_ptr, size_t default_data_size)
 
static bspl_dict_t * _wlmaker_config_from_plist (const char *fname_ptr)
 
bspl_object_t * wlmaker_config_object_load (wlmaker_files_t *files_ptr, const char *name_ptr, const char *arg_fname_ptr, const char *xdg_config_fname_ptr, const uint8_t *default_data_ptr, size_t default_data_size)
 
bspl_dict_t * wlmaker_config_load (wlmaker_files_t *files_ptr, const char *fname_ptr)
 
bspl_dict_t * wlmaker_state_load (wlmaker_files_t *files_ptr, const char *fname_ptr)
 
bool wlmaker_theme_load (wlmaker_files_t *files_ptr, const char *arg_fname_ptr, wlmaker_config_style_t *style_ptr)
 
static void test_embedded (bs_test_t *test_ptr)
 
static void test_file (bs_test_t *test_ptr)
 
static void test_style_file (bs_test_t *test_ptr)
 

Variables

static const bspl_desc_t _wlmaker_clip_style_desc []
 
const bspl_desc_t wlmaker_config_style_desc []
 
static const bs_test_case_t wlmaker_config_test_cases []
 
const bs_test_set_t wlmaker_config_test_set
 

Detailed Description

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Configurables for wlmaker. Currently, this file lists hardcoded entities, and mainly serves as a catalog about which entities should be dynamically configurable.

Function Documentation

◆ _wlmaker_config_from_plist()

bspl_dict_t * _wlmaker_config_from_plist ( const char *  fname_ptr)
static

Loads a plist dict from fname_ptr. Returns NULL on error.

◆ _wlmaker_plist_load()

bspl_object_t * _wlmaker_plist_load ( const char *  name_ptr,
const char *  fname_ptr,
const uint8_t *  default_data_ptr,
size_t  default_data_size 
)
static

Loads a plist object from the file or the default data.

◆ test_embedded()

void test_embedded ( bs_test_t *  test_ptr)
static

Verifies that the embedded config loads.

◆ test_file()

void test_file ( bs_test_t *  test_ptr)
static

Verifies that the (example) config files are loading.

◆ test_style_file()

void test_style_file ( bs_test_t *  test_ptr)
static

Loads and decodes the style file.

◆ wlmaker_config_load()

bspl_dict_t * wlmaker_config_load ( wlmaker_files_t files_ptr,
const char *  fname_ptr 
)

Loads the configuration for wlmaker.

Parameters
files_ptr
fname_ptrOptional: Name of the file to load it from. May be NULL.
Returns
A dict object, or NULL on error. Errors will already be logged. The caller must free the associated resources by calling bspl_object_unref().

◆ wlmaker_config_object_load()

bspl_object_t * wlmaker_config_object_load ( wlmaker_files_t files_ptr,
const char *  name_ptr,
const char *  arg_fname_ptr,
const char *  xdg_config_fname_ptr,
const uint8_t *  default_data_ptr,
size_t  default_data_size 
)

Loads a plist object from the given config file or data.

Useful to load configuration files from the provided name in fname_ptr or an in-memory buffer, as a compiled-in fallback option.

Parameters
files_ptr
name_ptrName to use when logging about the plist.
arg_fname_ptrExplicit filename to use for loading the file, eg. from the commandline. Or NULL.
xdg_config_fname_ptrFile name relative to XDG config home. See wlmaker_files_xdg_config_find.
default_data_ptrPoints to in-memory plist data, or NULL. Will be used if fname_ptr was NULL.
default_data_sizeThe size of the in-memory plist data.
Returns
a bspl_object_t on success, or NULL if none of the options had data, or if there was a file or parsing error.

◆ wlmaker_state_load()

bspl_dict_t * wlmaker_state_load ( wlmaker_files_t files_ptr,
const char *  fname_ptr 
)

Loads the state for wlmaker.

Behaviour is similar to wlmaker_config_load.

Parameters
files_ptr
fname_ptr
Returns
A dict object or NULL on error.

◆ wlmaker_theme_load()

bool wlmaker_theme_load ( wlmaker_files_t files_ptr,
const char *  fname_ptr,
wlmaker_config_style_t style_ptr 
)

Loads the theme file for wlmaker, stores into style_ptr.

Parameters
files_ptr
fname_ptrFile to load from. If NULL, will load the defualt style. Otherwise will try to locate the file relative to XDG Data directories.
style_ptrPoints to the style. If loading and decoding succeeds, resources at style_ptr will be freed. style_ptr is untouched on failure.
Returns
true on success.

Variable Documentation

◆ _wlmaker_clip_style_desc

const bspl_desc_t _wlmaker_clip_style_desc[]
static
Initial value:
= {
BSPL_DESC_DICT(
"Font", true, wlmaker_config_clip_style_t, font, font,
BSPL_DESC_ARGB32(
"TextColor", true, wlmaker_config_clip_style_t,
text_color, text_color, 0),
}
Definition config.h:52
const bspl_desc_t wlmtk_style_font_desc[]
Definition style.c:44

Descriptor for decoding the "Clip" dictionary.

◆ wlmaker_config_style_desc

const bspl_desc_t wlmaker_config_style_desc[]

Desciptor for decoding the style information from a plist.

◆ wlmaker_config_test_cases

const bs_test_case_t wlmaker_config_test_cases[]
static
Initial value:
= {
{ true, "embedded", test_embedded },
{ true, "file", test_file },
{ true, "style_file", test_style_file },
}
static void test_file(bs_test_t *test_ptr)
Definition config.c:297
static void test_style_file(bs_test_t *test_ptr)
Definition config.c:327
static void test_embedded(bs_test_t *test_ptr)
Definition config.c:269

Unit test cases.

◆ wlmaker_config_test_set

const bs_test_set_t wlmaker_config_test_set
Initial value:
= BS_TEST_SET(
true, "config", wlmaker_config_test_cases)
static const bs_test_case_t wlmaker_config_test_cases[]
Definition config.c:254

Unit test set.