/* wm_config_modifier.c generated by valac 0.56.19, the Vala compiler
 * generated from wm_config_modifier.vala, do not modify */

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <gobject/gvaluecollector.h>

#define WM_CONFIG_MODIFIER_LEGACY_BEGIN_MARKER "# BEGIN labwc-kbd\n"
#define WM_CONFIG_MODIFIER_LEGACY_END_MARKER "# END labwc-kbd\n"
#define WM_CONFIG_MODIFIER_CURRENT_BEGIN_MARKER "# BEGIN wl-kbd-config\n"
#define WM_CONFIG_MODIFIER_CURRENT_END_MARKER "# END wl-kbd-config\n"
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_WM_CONFIG_MODIFIER (wm_config_modifier_get_type ())
#define WM_CONFIG_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_WM_CONFIG_MODIFIER, WMConfigModifier))
#define WM_CONFIG_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_WM_CONFIG_MODIFIER, WMConfigModifierClass))
#define IS_WM_CONFIG_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_WM_CONFIG_MODIFIER))
#define IS_WM_CONFIG_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_WM_CONFIG_MODIFIER))
#define WM_CONFIG_MODIFIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_WM_CONFIG_MODIFIER, WMConfigModifierClass))

typedef struct _WMConfigModifier WMConfigModifier;
typedef struct _WMConfigModifierClass WMConfigModifierClass;
typedef struct _WMConfigModifierPrivate WMConfigModifierPrivate;
enum  {
	WM_CONFIG_MODIFIER_0_PROPERTY,
	WM_CONFIG_MODIFIER_NUM_PROPERTIES
};
static GParamSpec* wm_config_modifier_properties[WM_CONFIG_MODIFIER_NUM_PROPERTIES];
typedef enum  {
	WM_DETECTOR_WAYLAND_WM_LABWC,
	WM_DETECTOR_WAYLAND_WM_SWAY,
	WM_DETECTOR_WAYLAND_WM_WAYFIRE,
	WM_DETECTOR_WAYLAND_WM_RIVER,
	WM_DETECTOR_WAYLAND_WM_HYPRLAND,
	WM_DETECTOR_WAYLAND_WM_UNKNOWN
} WMDetectorWaylandWM;

#define WM_DETECTOR_TYPE_WAYLAND_WM (wm_detector_wayland_wm_get_type ())

#define WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG (wm_config_modifier_xkb_config_get_type ())
#define WM_CONFIG_MODIFIER_XKB_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG, WMConfigModifierXKBConfig))
#define WM_CONFIG_MODIFIER_XKB_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG, WMConfigModifierXKBConfigClass))
#define WM_CONFIG_MODIFIER_IS_XKB_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG))
#define WM_CONFIG_MODIFIER_IS_XKB_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG))
#define WM_CONFIG_MODIFIER_XKB_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG, WMConfigModifierXKBConfigClass))

typedef struct _WMConfigModifierXKBConfig WMConfigModifierXKBConfig;
typedef struct _WMConfigModifierXKBConfigClass WMConfigModifierXKBConfigClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _wm_config_modifier_xkb_config_unref0(var) ((var == NULL) ? NULL : (var = (wm_config_modifier_xkb_config_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
typedef struct _WMConfigModifierXKBConfigPrivate WMConfigModifierXKBConfigPrivate;
typedef struct _WMConfigModifierParamSpecXKBConfig WMConfigModifierParamSpecXKBConfig;

struct _WMConfigModifier {
	GObject parent_instance;
	WMConfigModifierPrivate * priv;
};

struct _WMConfigModifierClass {
	GObjectClass parent_class;
};

struct _WMConfigModifierXKBConfig {
	GTypeInstance parent_instance;
	volatile int ref_count;
	WMConfigModifierXKBConfigPrivate * priv;
};

struct _WMConfigModifierXKBConfigClass {
	GTypeClass parent_class;
	void (*finalize) (WMConfigModifierXKBConfig *self);
};

struct _WMConfigModifierXKBConfigPrivate {
	gchar* _layout;
	gchar* _variant;
	gchar* _options;
};

struct _WMConfigModifierParamSpecXKBConfig {
	GParamSpec parent_instance;
};

static gpointer wm_config_modifier_parent_class = NULL;
static gint WMConfigModifierXKBConfig_private_offset;
static gpointer wm_config_modifier_xkb_config_parent_class = NULL;

VALA_EXTERN GType wm_config_modifier_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WMConfigModifier, g_object_unref)
VALA_EXTERN GType wm_detector_wayland_wm_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gpointer wm_config_modifier_xkb_config_ref (gpointer instance);
VALA_EXTERN void wm_config_modifier_xkb_config_unref (gpointer instance);
VALA_EXTERN GParamSpec* wm_config_modifier_param_spec_xkb_config (const gchar* name,
                                                      const gchar* nick,
                                                      const gchar* blurb,
                                                      GType object_type,
                                                      GParamFlags flags);
VALA_EXTERN void wm_config_modifier_value_set_xkb_config (GValue* value,
                                              gpointer v_object);
VALA_EXTERN void wm_config_modifier_value_take_xkb_config (GValue* value,
                                               gpointer v_object);
VALA_EXTERN gpointer wm_config_modifier_value_get_xkb_config (const GValue* value);
VALA_EXTERN GType wm_config_modifier_xkb_config_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WMConfigModifierXKBConfig, wm_config_modifier_xkb_config_unref)
VALA_EXTERN WMConfigModifierXKBConfig* wm_config_modifier_read_from_wm (WMDetectorWaylandWM wm,
                                                            GError** error);
static WMConfigModifierXKBConfig* wm_config_modifier_read_labwc_config (void);
static WMConfigModifierXKBConfig* wm_config_modifier_read_sway_config (void);
static WMConfigModifierXKBConfig* wm_config_modifier_read_wayfire_config (void);
static WMConfigModifierXKBConfig* wm_config_modifier_read_river_config (void);
static WMConfigModifierXKBConfig* wm_config_modifier_read_hyprland_config (void);
VALA_EXTERN gboolean wm_config_modifier_apply_to_wm (WMDetectorWaylandWM wm,
                                         WMConfigModifierXKBConfig* config,
                                         GError** error);
VALA_EXTERN gchar* wm_detector_get_config_path (WMDetectorWaylandWM wm);
static gboolean wm_config_modifier_apply_to_labwc (WMConfigModifierXKBConfig* config,
                                            GError** error);
static gboolean wm_config_modifier_apply_to_sway (WMConfigModifierXKBConfig* config,
                                           GError** error);
static gboolean wm_config_modifier_apply_to_wayfire (WMConfigModifierXKBConfig* config,
                                              GError** error);
static gboolean wm_config_modifier_apply_to_river (WMConfigModifierXKBConfig* config,
                                            GError** error);
static gboolean wm_config_modifier_apply_to_hyprland (WMConfigModifierXKBConfig* config,
                                               GError** error);
VALA_EXTERN WMConfigModifierXKBConfig* wm_config_modifier_xkb_config_new (void);
VALA_EXTERN WMConfigModifierXKBConfig* wm_config_modifier_xkb_config_construct (GType object_type);
VALA_EXTERN void wm_config_modifier_xkb_config_set_layout (WMConfigModifierXKBConfig* self,
                                               const gchar* value);
VALA_EXTERN void wm_config_modifier_xkb_config_set_variant (WMConfigModifierXKBConfig* self,
                                                const gchar* value);
VALA_EXTERN void wm_config_modifier_xkb_config_set_options (WMConfigModifierXKBConfig* self,
                                                const gchar* value);
static WMConfigModifierXKBConfig* wm_config_modifier_read_xkb_from_config_file (const gchar* path);
static gchar* wm_config_modifier_extract_env_value (const gchar* line,
                                             const gchar* var_name);
static gboolean wm_config_modifier_apply_env_exports (const gchar* path,
                                               WMConfigModifierXKBConfig* config,
                                               GError** error);
static gboolean wm_config_modifier_apply_input_block (const gchar* path,
                                               const gchar* block_prefix,
                                               WMConfigModifierXKBConfig* config,
                                               GError** error);
static gboolean wm_config_modifier_apply_wayfire_section (const gchar* path,
                                                   WMConfigModifierXKBConfig* config,
                                                   GError** error);
static gboolean wm_config_modifier_apply_hyprland_env (const gchar* path,
                                                WMConfigModifierXKBConfig* config,
                                                GError** error);
VALA_EXTERN const gchar* wm_config_modifier_xkb_config_get_layout (WMConfigModifierXKBConfig* self);
VALA_EXTERN const gchar* wm_config_modifier_xkb_config_get_options (WMConfigModifierXKBConfig* self);
VALA_EXTERN gboolean wm_config_modifier_test_apply_env_exports (const gchar* path,
                                                    WMConfigModifierXKBConfig* config,
                                                    GError** error);
VALA_EXTERN WMConfigModifier* wm_config_modifier_new (void);
VALA_EXTERN WMConfigModifier* wm_config_modifier_construct (GType object_type);
VALA_EXTERN gchar* wm_config_modifier_xkb_config_to_env_string (WMConfigModifierXKBConfig* self);
VALA_EXTERN const gchar* wm_config_modifier_xkb_config_get_variant (WMConfigModifierXKBConfig* self);
static void wm_config_modifier_xkb_config_finalize (WMConfigModifierXKBConfig * obj);
static GType wm_config_modifier_xkb_config_get_type_once (void);
static GType wm_config_modifier_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);

WMConfigModifierXKBConfig*
wm_config_modifier_read_from_wm (WMDetectorWaylandWM wm,
                                 GError** error)
{
	WMConfigModifierXKBConfig* result;
	switch (wm) {
		case WM_DETECTOR_WAYLAND_WM_LABWC:
		{
			WMConfigModifierXKBConfig* _tmp0_;
			_tmp0_ = wm_config_modifier_read_labwc_config ();
			result = _tmp0_;
			return result;
		}
		case WM_DETECTOR_WAYLAND_WM_SWAY:
		{
			WMConfigModifierXKBConfig* _tmp1_;
			_tmp1_ = wm_config_modifier_read_sway_config ();
			result = _tmp1_;
			return result;
		}
		case WM_DETECTOR_WAYLAND_WM_WAYFIRE:
		{
			WMConfigModifierXKBConfig* _tmp2_;
			_tmp2_ = wm_config_modifier_read_wayfire_config ();
			result = _tmp2_;
			return result;
		}
		case WM_DETECTOR_WAYLAND_WM_RIVER:
		{
			WMConfigModifierXKBConfig* _tmp3_;
			_tmp3_ = wm_config_modifier_read_river_config ();
			result = _tmp3_;
			return result;
		}
		case WM_DETECTOR_WAYLAND_WM_HYPRLAND:
		{
			WMConfigModifierXKBConfig* _tmp4_;
			_tmp4_ = wm_config_modifier_read_hyprland_config ();
			result = _tmp4_;
			return result;
		}
		default:
		{
			result = NULL;
			return result;
		}
	}
}

gboolean
wm_config_modifier_apply_to_wm (WMDetectorWaylandWM wm,
                                WMConfigModifierXKBConfig* config,
                                GError** error)
{
	gchar* config_path = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (config != NULL, FALSE);
	_tmp0_ = wm_detector_get_config_path (wm);
	config_path = _tmp0_;
	_tmp1_ = config_path;
	if (!g_file_test (_tmp1_, G_FILE_TEST_EXISTS)) {
		result = FALSE;
		_g_free0 (config_path);
		return result;
	}
	switch (wm) {
		case WM_DETECTOR_WAYLAND_WM_LABWC:
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = wm_config_modifier_apply_to_labwc (config, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				gboolean _tmp3_ = FALSE;
				g_propagate_error (error, _inner_error0_);
				_g_free0 (config_path);
				return _tmp3_;
			}
			result = _tmp2_;
			_g_free0 (config_path);
			return result;
		}
		case WM_DETECTOR_WAYLAND_WM_SWAY:
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = wm_config_modifier_apply_to_sway (config, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				gboolean _tmp5_ = FALSE;
				g_propagate_error (error, _inner_error0_);
				_g_free0 (config_path);
				return _tmp5_;
			}
			result = _tmp4_;
			_g_free0 (config_path);
			return result;
		}
		case WM_DETECTOR_WAYLAND_WM_WAYFIRE:
		{
			gboolean _tmp6_ = FALSE;
			_tmp6_ = wm_config_modifier_apply_to_wayfire (config, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				gboolean _tmp7_ = FALSE;
				g_propagate_error (error, _inner_error0_);
				_g_free0 (config_path);
				return _tmp7_;
			}
			result = _tmp6_;
			_g_free0 (config_path);
			return result;
		}
		case WM_DETECTOR_WAYLAND_WM_RIVER:
		{
			gboolean _tmp8_ = FALSE;
			_tmp8_ = wm_config_modifier_apply_to_river (config, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				gboolean _tmp9_ = FALSE;
				g_propagate_error (error, _inner_error0_);
				_g_free0 (config_path);
				return _tmp9_;
			}
			result = _tmp8_;
			_g_free0 (config_path);
			return result;
		}
		case WM_DETECTOR_WAYLAND_WM_HYPRLAND:
		{
			gboolean _tmp10_ = FALSE;
			_tmp10_ = wm_config_modifier_apply_to_hyprland (config, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				gboolean _tmp11_ = FALSE;
				g_propagate_error (error, _inner_error0_);
				_g_free0 (config_path);
				return _tmp11_;
			}
			result = _tmp10_;
			_g_free0 (config_path);
			return result;
		}
		default:
		{
			result = FALSE;
			_g_free0 (config_path);
			return result;
		}
	}
}

static WMConfigModifierXKBConfig*
wm_config_modifier_read_labwc_config (void)
{
	WMConfigModifierXKBConfig* config = NULL;
	WMConfigModifierXKBConfig* _tmp0_;
	const gchar* _tmp1_ = NULL;
	const gchar* _tmp2_;
	WMConfigModifierXKBConfig* _tmp3_;
	const gchar* _tmp4_ = NULL;
	const gchar* _tmp5_;
	WMConfigModifierXKBConfig* _tmp6_;
	const gchar* _tmp7_ = NULL;
	const gchar* _tmp8_;
	WMConfigModifierXKBConfig* _tmp9_;
	WMConfigModifierXKBConfig* result;
	_tmp0_ = wm_config_modifier_xkb_config_new ();
	config = _tmp0_;
	_tmp2_ = g_getenv ("XKB_DEFAULT_LAYOUT");
	_tmp1_ = _tmp2_;
	if (_tmp1_ == NULL) {
		_tmp1_ = "us";
	}
	_tmp3_ = config;
	wm_config_modifier_xkb_config_set_layout (_tmp3_, _tmp1_);
	_tmp5_ = g_getenv ("XKB_DEFAULT_VARIANT");
	_tmp4_ = _tmp5_;
	if (_tmp4_ == NULL) {
		_tmp4_ = "";
	}
	_tmp6_ = config;
	wm_config_modifier_xkb_config_set_variant (_tmp6_, _tmp4_);
	_tmp8_ = g_getenv ("XKB_DEFAULT_OPTIONS");
	_tmp7_ = _tmp8_;
	if (_tmp7_ == NULL) {
		_tmp7_ = "";
	}
	_tmp9_ = config;
	wm_config_modifier_xkb_config_set_options (_tmp9_, _tmp7_);
	result = config;
	return result;
}

static WMConfigModifierXKBConfig*
wm_config_modifier_read_sway_config (void)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	WMConfigModifierXKBConfig* _tmp3_;
	WMConfigModifierXKBConfig* _tmp4_;
	WMConfigModifierXKBConfig* result;
	_tmp0_ = g_get_home_dir ();
	_tmp1_ = g_build_filename (_tmp0_, ".config", "sway", "config", NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = wm_config_modifier_read_xkb_from_config_file (_tmp2_);
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	result = _tmp4_;
	return result;
}

static WMConfigModifierXKBConfig*
wm_config_modifier_read_wayfire_config (void)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	WMConfigModifierXKBConfig* _tmp3_;
	WMConfigModifierXKBConfig* _tmp4_;
	WMConfigModifierXKBConfig* result;
	_tmp0_ = g_get_home_dir ();
	_tmp1_ = g_build_filename (_tmp0_, ".config", "wayfire.ini", NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = wm_config_modifier_read_xkb_from_config_file (_tmp2_);
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	result = _tmp4_;
	return result;
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static WMConfigModifierXKBConfig*
wm_config_modifier_read_river_config (void)
{
	WMConfigModifierXKBConfig* config = NULL;
	WMConfigModifierXKBConfig* _tmp0_;
	gchar* init_path = NULL;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	GError* _inner_error0_ = NULL;
	WMConfigModifierXKBConfig* result;
	_tmp0_ = wm_config_modifier_xkb_config_new ();
	config = _tmp0_;
	_tmp1_ = g_get_home_dir ();
	_tmp2_ = g_build_filename (_tmp1_, ".config", "river", "init", NULL);
	init_path = _tmp2_;
	_tmp3_ = init_path;
	if (!g_file_test (_tmp3_, G_FILE_TEST_EXISTS)) {
		result = NULL;
		_g_free0 (init_path);
		_wm_config_modifier_xkb_config_unref0 (config);
		return result;
	}
	{
		gchar* content = NULL;
		const gchar* _tmp4_;
		gchar* _tmp5_ = NULL;
		gchar** lines = NULL;
		const gchar* _tmp6_;
		gchar** _tmp7_;
		gchar** _tmp8_;
		gint lines_length1;
		gint _lines_size_;
		gchar** _tmp9_;
		gint _tmp9__length1;
		_tmp4_ = init_path;
		g_file_get_contents (_tmp4_, &_tmp5_, NULL, &_inner_error0_);
		_g_free0 (content);
		content = _tmp5_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (content);
			goto __catch0_g_error;
		}
		_tmp6_ = content;
		_tmp8_ = _tmp7_ = g_strsplit (_tmp6_, "\n", 0);
		lines = _tmp8_;
		lines_length1 = _vala_array_length (_tmp7_);
		_lines_size_ = lines_length1;
		_tmp9_ = lines;
		_tmp9__length1 = lines_length1;
		{
			gchar** line_collection = NULL;
			gint line_collection_length1 = 0;
			gint _line_collection_size_ = 0;
			gint line_it = 0;
			line_collection = _tmp9_;
			line_collection_length1 = _tmp9__length1;
			for (line_it = 0; line_it < line_collection_length1; line_it = line_it + 1) {
				gchar* _tmp10_;
				gchar* line = NULL;
				_tmp10_ = g_strdup (line_collection[line_it]);
				line = _tmp10_;
				{
					const gchar* _tmp11_;
					_tmp11_ = line;
					if (string_contains (_tmp11_, "XKB_DEFAULT_LAYOUT")) {
						gchar* value = NULL;
						const gchar* _tmp12_;
						gchar* _tmp13_;
						const gchar* _tmp14_;
						_tmp12_ = line;
						_tmp13_ = wm_config_modifier_extract_env_value (_tmp12_, "XKB_DEFAULT_LAYOUT");
						value = _tmp13_;
						_tmp14_ = value;
						if (g_strcmp0 (_tmp14_, "") != 0) {
							WMConfigModifierXKBConfig* _tmp15_;
							const gchar* _tmp16_;
							_tmp15_ = config;
							_tmp16_ = value;
							wm_config_modifier_xkb_config_set_layout (_tmp15_, _tmp16_);
						}
						_g_free0 (value);
					} else {
						const gchar* _tmp17_;
						_tmp17_ = line;
						if (string_contains (_tmp17_, "XKB_DEFAULT_OPTIONS")) {
							gchar* value = NULL;
							const gchar* _tmp18_;
							gchar* _tmp19_;
							const gchar* _tmp20_;
							_tmp18_ = line;
							_tmp19_ = wm_config_modifier_extract_env_value (_tmp18_, "XKB_DEFAULT_OPTIONS");
							value = _tmp19_;
							_tmp20_ = value;
							if (g_strcmp0 (_tmp20_, "") != 0) {
								WMConfigModifierXKBConfig* _tmp21_;
								const gchar* _tmp22_;
								_tmp21_ = config;
								_tmp22_ = value;
								wm_config_modifier_xkb_config_set_options (_tmp21_, _tmp22_);
							}
							_g_free0 (value);
						}
					}
					_g_free0 (line);
				}
			}
		}
		lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (content);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp23_;
		const gchar* _tmp24_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp23_ = e;
		_tmp24_ = _tmp23_->message;
		g_warning ("wm_config_modifier.vala:118: Failed to read river config: %s", _tmp24_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (init_path);
		_wm_config_modifier_xkb_config_unref0 (config);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	result = config;
	_g_free0 (init_path);
	return result;
}

static gint
string_index_of (const gchar* self,
                 const gchar* needle,
                 gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (needle != NULL, -1);
	_tmp0_ = strstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static gint
string_index_of_char (const gchar* self,
                      gunichar c,
                      gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = g_utf8_strchr (((gchar*) self) + start_index, (gssize) -1, c);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

static gint
string_last_index_of (const gchar* self,
                      const gchar* needle,
                      gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (needle != NULL, -1);
	_tmp0_ = g_strrstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static gchar*
wm_config_modifier_extract_env_value (const gchar* line,
                                      const gchar* var_name)
{
	gint start = 0;
	gint eq_pos = 0;
	gchar* rest = NULL;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp10_;
	gchar** parts = NULL;
	const gchar* _tmp14_;
	gchar** _tmp15_;
	gchar** _tmp16_;
	gint parts_length1;
	gint _parts_size_;
	gchar** _tmp17_;
	gint _tmp17__length1;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* result;
	g_return_val_if_fail (line != NULL, NULL);
	g_return_val_if_fail (var_name != NULL, NULL);
	start = string_index_of (line, var_name, 0);
	if (start < 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("");
		result = _tmp0_;
		return result;
	}
	eq_pos = string_index_of_char (line, (gunichar) '=', start);
	if (eq_pos < 0) {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("");
		result = _tmp1_;
		return result;
	}
	_tmp2_ = string_substring (line, (glong) (eq_pos + 1), (glong) -1);
	_tmp3_ = _tmp2_;
	_tmp4_ = string_strip (_tmp3_);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp3_);
	rest = _tmp5_;
	_tmp6_ = rest;
	if (g_str_has_prefix (_tmp6_, "\"")) {
		gint end = 0;
		const gchar* _tmp7_;
		_tmp7_ = rest;
		end = string_last_index_of (_tmp7_, "\"", 0);
		if (end > 1) {
			const gchar* _tmp8_;
			gchar* _tmp9_;
			_tmp8_ = rest;
			_tmp9_ = string_substring (_tmp8_, (glong) 1, (glong) (end - 1));
			result = _tmp9_;
			_g_free0 (rest);
			return result;
		}
	}
	_tmp10_ = rest;
	if (g_str_has_prefix (_tmp10_, "'")) {
		gint end = 0;
		const gchar* _tmp11_;
		_tmp11_ = rest;
		end = string_last_index_of (_tmp11_, "'", 0);
		if (end > 1) {
			const gchar* _tmp12_;
			gchar* _tmp13_;
			_tmp12_ = rest;
			_tmp13_ = string_substring (_tmp12_, (glong) 1, (glong) (end - 1));
			result = _tmp13_;
			_g_free0 (rest);
			return result;
		}
	}
	_tmp14_ = rest;
	_tmp16_ = _tmp15_ = g_strsplit (_tmp14_, " ", 0);
	parts = _tmp16_;
	parts_length1 = _vala_array_length (_tmp15_);
	_parts_size_ = parts_length1;
	_tmp17_ = parts;
	_tmp17__length1 = parts_length1;
	_tmp18_ = _tmp17_[0];
	_tmp19_ = g_strdup (_tmp18_);
	result = _tmp19_;
	parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (rest);
	return result;
}

static WMConfigModifierXKBConfig*
wm_config_modifier_read_hyprland_config (void)
{
	WMConfigModifierXKBConfig* config = NULL;
	WMConfigModifierXKBConfig* _tmp0_;
	gchar* conf_path = NULL;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	GError* _inner_error0_ = NULL;
	WMConfigModifierXKBConfig* result;
	_tmp0_ = wm_config_modifier_xkb_config_new ();
	config = _tmp0_;
	_tmp1_ = g_get_home_dir ();
	_tmp2_ = g_build_filename (_tmp1_, ".config", "hypr", "hyprland.conf", NULL);
	conf_path = _tmp2_;
	_tmp3_ = conf_path;
	if (!g_file_test (_tmp3_, G_FILE_TEST_EXISTS)) {
		result = NULL;
		_g_free0 (conf_path);
		_wm_config_modifier_xkb_config_unref0 (config);
		return result;
	}
	{
		gchar* content = NULL;
		const gchar* _tmp4_;
		gchar* _tmp5_ = NULL;
		gchar** lines = NULL;
		const gchar* _tmp6_;
		gchar** _tmp7_;
		gchar** _tmp8_;
		gint lines_length1;
		gint _lines_size_;
		gchar** _tmp9_;
		gint _tmp9__length1;
		_tmp4_ = conf_path;
		g_file_get_contents (_tmp4_, &_tmp5_, NULL, &_inner_error0_);
		_g_free0 (content);
		content = _tmp5_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (content);
			goto __catch0_g_error;
		}
		_tmp6_ = content;
		_tmp8_ = _tmp7_ = g_strsplit (_tmp6_, "\n", 0);
		lines = _tmp8_;
		lines_length1 = _vala_array_length (_tmp7_);
		_lines_size_ = lines_length1;
		_tmp9_ = lines;
		_tmp9__length1 = lines_length1;
		{
			gchar** line_collection = NULL;
			gint line_collection_length1 = 0;
			gint _line_collection_size_ = 0;
			gint line_it = 0;
			line_collection = _tmp9_;
			line_collection_length1 = _tmp9__length1;
			for (line_it = 0; line_it < line_collection_length1; line_it = line_it + 1) {
				gchar* _tmp10_;
				gchar* line = NULL;
				_tmp10_ = g_strdup (line_collection[line_it]);
				line = _tmp10_;
				{
					gboolean _tmp11_ = FALSE;
					const gchar* _tmp12_;
					_tmp12_ = line;
					if (g_str_has_prefix (_tmp12_, "env = XKB_DEFAULT_LAYOUT")) {
						_tmp11_ = TRUE;
					} else {
						const gchar* _tmp13_;
						_tmp13_ = line;
						_tmp11_ = g_str_has_prefix (_tmp13_, "env=XKB_DEFAULT_LAYOUT");
					}
					if (_tmp11_) {
						gchar** parts = NULL;
						const gchar* _tmp14_;
						gchar** _tmp15_;
						gchar** _tmp16_;
						gint parts_length1;
						gint _parts_size_;
						gchar** _tmp17_;
						gint _tmp17__length1;
						_tmp14_ = line;
						_tmp16_ = _tmp15_ = g_strsplit (_tmp14_, ",", 0);
						parts = _tmp16_;
						parts_length1 = _vala_array_length (_tmp15_);
						_parts_size_ = parts_length1;
						_tmp17_ = parts;
						_tmp17__length1 = parts_length1;
						if (_tmp17__length1 >= 2) {
							WMConfigModifierXKBConfig* _tmp18_;
							gchar** _tmp19_;
							gint _tmp19__length1;
							const gchar* _tmp20_;
							gchar* _tmp21_;
							gchar* _tmp22_;
							_tmp18_ = config;
							_tmp19_ = parts;
							_tmp19__length1 = parts_length1;
							_tmp20_ = _tmp19_[1];
							_tmp21_ = string_strip (_tmp20_);
							_tmp22_ = _tmp21_;
							wm_config_modifier_xkb_config_set_layout (_tmp18_, _tmp22_);
							_g_free0 (_tmp22_);
						}
						parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
					} else {
						gboolean _tmp23_ = FALSE;
						const gchar* _tmp24_;
						_tmp24_ = line;
						if (g_str_has_prefix (_tmp24_, "env = XKB_DEFAULT_OPTIONS")) {
							_tmp23_ = TRUE;
						} else {
							const gchar* _tmp25_;
							_tmp25_ = line;
							_tmp23_ = g_str_has_prefix (_tmp25_, "env=XKB_DEFAULT_OPTIONS");
						}
						if (_tmp23_) {
							gchar** parts = NULL;
							const gchar* _tmp26_;
							gchar** _tmp27_;
							gchar** _tmp28_;
							gint parts_length1;
							gint _parts_size_;
							gchar** _tmp29_;
							gint _tmp29__length1;
							_tmp26_ = line;
							_tmp28_ = _tmp27_ = g_strsplit (_tmp26_, ",", 0);
							parts = _tmp28_;
							parts_length1 = _vala_array_length (_tmp27_);
							_parts_size_ = parts_length1;
							_tmp29_ = parts;
							_tmp29__length1 = parts_length1;
							if (_tmp29__length1 >= 2) {
								WMConfigModifierXKBConfig* _tmp30_;
								gchar** _tmp31_;
								gint _tmp31__length1;
								const gchar* _tmp32_;
								gchar* _tmp33_;
								gchar* _tmp34_;
								_tmp30_ = config;
								_tmp31_ = parts;
								_tmp31__length1 = parts_length1;
								_tmp32_ = _tmp31_[1];
								_tmp33_ = string_strip (_tmp32_);
								_tmp34_ = _tmp33_;
								wm_config_modifier_xkb_config_set_options (_tmp30_, _tmp34_);
								_g_free0 (_tmp34_);
							}
							parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
						}
					}
					_g_free0 (line);
				}
			}
		}
		lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (content);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp35_;
		const gchar* _tmp36_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp35_ = e;
		_tmp36_ = _tmp35_->message;
		g_warning ("wm_config_modifier.vala:176: Failed to read hyprland config: %s", _tmp36_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (conf_path);
		_wm_config_modifier_xkb_config_unref0 (config);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	result = config;
	_g_free0 (conf_path);
	return result;
}

static WMConfigModifierXKBConfig*
wm_config_modifier_read_xkb_from_config_file (const gchar* path)
{
	WMConfigModifierXKBConfig* config = NULL;
	WMConfigModifierXKBConfig* _tmp0_;
	GError* _inner_error0_ = NULL;
	WMConfigModifierXKBConfig* result;
	g_return_val_if_fail (path != NULL, NULL);
	_tmp0_ = wm_config_modifier_xkb_config_new ();
	config = _tmp0_;
	if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
		result = NULL;
		_wm_config_modifier_xkb_config_unref0 (config);
		return result;
	}
	{
		gchar* content = NULL;
		gchar* _tmp1_ = NULL;
		gchar** lines = NULL;
		const gchar* _tmp2_;
		gchar** _tmp3_;
		gchar** _tmp4_;
		gint lines_length1;
		gint _lines_size_;
		gchar** _tmp5_;
		gint _tmp5__length1;
		g_file_get_contents (path, &_tmp1_, NULL, &_inner_error0_);
		_g_free0 (content);
		content = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (content);
			goto __catch0_g_error;
		}
		_tmp2_ = content;
		_tmp4_ = _tmp3_ = g_strsplit (_tmp2_, "\n", 0);
		lines = _tmp4_;
		lines_length1 = _vala_array_length (_tmp3_);
		_lines_size_ = lines_length1;
		_tmp5_ = lines;
		_tmp5__length1 = lines_length1;
		{
			gchar** line_collection = NULL;
			gint line_collection_length1 = 0;
			gint _line_collection_size_ = 0;
			gint line_it = 0;
			line_collection = _tmp5_;
			line_collection_length1 = _tmp5__length1;
			for (line_it = 0; line_it < line_collection_length1; line_it = line_it + 1) {
				gchar* _tmp6_;
				gchar* line = NULL;
				_tmp6_ = g_strdup (line_collection[line_it]);
				line = _tmp6_;
				{
					gchar* trimmed = NULL;
					const gchar* _tmp7_;
					gchar* _tmp8_;
					const gchar* _tmp9_;
					_tmp7_ = line;
					_tmp8_ = string_strip (_tmp7_);
					trimmed = _tmp8_;
					_tmp9_ = trimmed;
					if (g_str_has_prefix (_tmp9_, "xkb_layout")) {
						gchar** parts = NULL;
						const gchar* _tmp10_;
						gchar** _tmp11_;
						gchar** _tmp12_;
						gint parts_length1;
						gint _parts_size_;
						gchar** _tmp13_;
						gint _tmp13__length1;
						_tmp10_ = trimmed;
						_tmp12_ = _tmp11_ = g_strsplit (_tmp10_, " ", 0);
						parts = _tmp12_;
						parts_length1 = _vala_array_length (_tmp11_);
						_parts_size_ = parts_length1;
						_tmp13_ = parts;
						_tmp13__length1 = parts_length1;
						if (_tmp13__length1 >= 2) {
							WMConfigModifierXKBConfig* _tmp14_;
							gchar** _tmp15_;
							gint _tmp15__length1;
							const gchar* _tmp16_;
							_tmp14_ = config;
							_tmp15_ = parts;
							_tmp15__length1 = parts_length1;
							_tmp16_ = _tmp15_[1];
							wm_config_modifier_xkb_config_set_layout (_tmp14_, _tmp16_);
						}
						parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
					} else {
						const gchar* _tmp17_;
						_tmp17_ = trimmed;
						if (g_str_has_prefix (_tmp17_, "xkb_options")) {
							gchar** parts = NULL;
							const gchar* _tmp18_;
							gchar** _tmp19_;
							gchar** _tmp20_;
							gint parts_length1;
							gint _parts_size_;
							gchar** _tmp21_;
							gint _tmp21__length1;
							_tmp18_ = trimmed;
							_tmp20_ = _tmp19_ = g_strsplit (_tmp18_, " ", 0);
							parts = _tmp20_;
							parts_length1 = _vala_array_length (_tmp19_);
							_parts_size_ = parts_length1;
							_tmp21_ = parts;
							_tmp21__length1 = parts_length1;
							if (_tmp21__length1 >= 2) {
								WMConfigModifierXKBConfig* _tmp22_;
								gchar** _tmp23_;
								gint _tmp23__length1;
								const gchar* _tmp24_;
								_tmp22_ = config;
								_tmp23_ = parts;
								_tmp23__length1 = parts_length1;
								_tmp24_ = _tmp23_[1];
								wm_config_modifier_xkb_config_set_options (_tmp22_, _tmp24_);
							}
							parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
						} else {
							const gchar* _tmp25_;
							_tmp25_ = trimmed;
							if (g_str_has_prefix (_tmp25_, "kb_layout")) {
								gchar** parts = NULL;
								const gchar* _tmp26_;
								gchar** _tmp27_;
								gchar** _tmp28_;
								gint parts_length1;
								gint _parts_size_;
								gchar** _tmp29_;
								gint _tmp29__length1;
								_tmp26_ = trimmed;
								_tmp28_ = _tmp27_ = g_strsplit (_tmp26_, "=", 0);
								parts = _tmp28_;
								parts_length1 = _vala_array_length (_tmp27_);
								_parts_size_ = parts_length1;
								_tmp29_ = parts;
								_tmp29__length1 = parts_length1;
								if (_tmp29__length1 >= 2) {
									WMConfigModifierXKBConfig* _tmp30_;
									gchar** _tmp31_;
									gint _tmp31__length1;
									const gchar* _tmp32_;
									gchar* _tmp33_;
									gchar* _tmp34_;
									_tmp30_ = config;
									_tmp31_ = parts;
									_tmp31__length1 = parts_length1;
									_tmp32_ = _tmp31_[1];
									_tmp33_ = string_strip (_tmp32_);
									_tmp34_ = _tmp33_;
									wm_config_modifier_xkb_config_set_layout (_tmp30_, _tmp34_);
									_g_free0 (_tmp34_);
								}
								parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
							} else {
								const gchar* _tmp35_;
								_tmp35_ = trimmed;
								if (g_str_has_prefix (_tmp35_, "kb_options")) {
									gchar** parts = NULL;
									const gchar* _tmp36_;
									gchar** _tmp37_;
									gchar** _tmp38_;
									gint parts_length1;
									gint _parts_size_;
									gchar** _tmp39_;
									gint _tmp39__length1;
									_tmp36_ = trimmed;
									_tmp38_ = _tmp37_ = g_strsplit (_tmp36_, "=", 0);
									parts = _tmp38_;
									parts_length1 = _vala_array_length (_tmp37_);
									_parts_size_ = parts_length1;
									_tmp39_ = parts;
									_tmp39__length1 = parts_length1;
									if (_tmp39__length1 >= 2) {
										WMConfigModifierXKBConfig* _tmp40_;
										gchar** _tmp41_;
										gint _tmp41__length1;
										const gchar* _tmp42_;
										gchar* _tmp43_;
										gchar* _tmp44_;
										_tmp40_ = config;
										_tmp41_ = parts;
										_tmp41__length1 = parts_length1;
										_tmp42_ = _tmp41_[1];
										_tmp43_ = string_strip (_tmp42_);
										_tmp44_ = _tmp43_;
										wm_config_modifier_xkb_config_set_options (_tmp40_, _tmp44_);
										_g_free0 (_tmp44_);
									}
									parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
								}
							}
						}
					}
					_g_free0 (trimmed);
					_g_free0 (line);
				}
			}
		}
		lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (content);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp45_;
		const gchar* _tmp46_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp45_ = e;
		_tmp46_ = _tmp45_->message;
		g_warning ("wm_config_modifier.vala:219: Failed to read config: %s", _tmp46_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_wm_config_modifier_xkb_config_unref0 (config);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	result = config;
	return result;
}

static gboolean
wm_config_modifier_apply_to_labwc (WMConfigModifierXKBConfig* config,
                                   GError** error)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gboolean _tmp4_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (config != NULL, FALSE);
	_tmp1_ = g_get_home_dir ();
	_tmp2_ = g_build_filename (_tmp1_, ".config", "labwc", "autostart", NULL);
	_tmp3_ = _tmp2_;
	_tmp4_ = wm_config_modifier_apply_env_exports (_tmp3_, config, &_inner_error0_);
	_g_free0 (_tmp3_);
	_tmp0_ = _tmp4_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp5_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp5_;
	}
	result = _tmp0_;
	return result;
}

static gboolean
wm_config_modifier_apply_to_sway (WMConfigModifierXKBConfig* config,
                                  GError** error)
{
	gchar* config_path = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_ = FALSE;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (config != NULL, FALSE);
	_tmp0_ = g_get_home_dir ();
	_tmp1_ = g_build_filename (_tmp0_, ".config", "sway", "config", NULL);
	config_path = _tmp1_;
	_tmp2_ = wm_config_modifier_apply_input_block (config_path, "input *", config, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp3_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_g_free0 (config_path);
		return _tmp3_;
	}
	result = _tmp2_;
	_g_free0 (config_path);
	return result;
}

static gboolean
wm_config_modifier_apply_to_wayfire (WMConfigModifierXKBConfig* config,
                                     GError** error)
{
	gchar* config_path = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_ = FALSE;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (config != NULL, FALSE);
	_tmp0_ = g_get_home_dir ();
	_tmp1_ = g_build_filename (_tmp0_, ".config", "wayfire.ini", NULL);
	config_path = _tmp1_;
	_tmp2_ = wm_config_modifier_apply_wayfire_section (config_path, config, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp3_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_g_free0 (config_path);
		return _tmp3_;
	}
	result = _tmp2_;
	_g_free0 (config_path);
	return result;
}

static gboolean
wm_config_modifier_apply_to_river (WMConfigModifierXKBConfig* config,
                                   GError** error)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gboolean _tmp4_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (config != NULL, FALSE);
	_tmp1_ = g_get_home_dir ();
	_tmp2_ = g_build_filename (_tmp1_, ".config", "river", "init", NULL);
	_tmp3_ = _tmp2_;
	_tmp4_ = wm_config_modifier_apply_env_exports (_tmp3_, config, &_inner_error0_);
	_g_free0 (_tmp3_);
	_tmp0_ = _tmp4_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp5_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp5_;
	}
	result = _tmp0_;
	return result;
}

static gboolean
wm_config_modifier_apply_to_hyprland (WMConfigModifierXKBConfig* config,
                                      GError** error)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gboolean _tmp4_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (config != NULL, FALSE);
	_tmp1_ = g_get_home_dir ();
	_tmp2_ = g_build_filename (_tmp1_, ".config", "hypr", "hyprland.conf", NULL);
	_tmp3_ = _tmp2_;
	_tmp4_ = wm_config_modifier_apply_hyprland_env (_tmp3_, config, &_inner_error0_);
	_g_free0 (_tmp3_);
	_tmp0_ = _tmp4_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp5_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp5_;
	}
	result = _tmp0_;
	return result;
}

static gchar*
string_slice (const gchar* self,
              glong start,
              glong end)
{
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	if (start < ((glong) 0)) {
		start = string_length + start;
	}
	if (end < ((glong) 0)) {
		end = string_length + end;
	}
	if (start >= ((glong) 0)) {
		_tmp2_ = start <= string_length;
	} else {
		_tmp2_ = FALSE;
	}
	g_return_val_if_fail (_tmp2_, NULL);
	if (end >= ((glong) 0)) {
		_tmp3_ = end <= string_length;
	} else {
		_tmp3_ = FALSE;
	}
	g_return_val_if_fail (_tmp3_, NULL);
	g_return_val_if_fail (start <= end, NULL);
	_tmp4_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
	result = _tmp4_;
	return result;
}

static gboolean
wm_config_modifier_apply_env_exports (const gchar* path,
                                      WMConfigModifierXKBConfig* config,
                                      GError** error)
{
	gchar* existing = NULL;
	gchar* _tmp0_;
	gchar** begin_markers = NULL;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar** _tmp5_;
	gint begin_markers_length1;
	gint _begin_markers_size_;
	gchar** end_markers = NULL;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar** _tmp8_;
	gint end_markers_length1;
	gint _end_markers_size_;
	const gchar* _tmp33_;
	gchar* _tmp34_;
	GString* sb = NULL;
	GString* _tmp35_;
	const gchar* _tmp36_;
	gint _tmp37_;
	gint _tmp38_;
	GString* _tmp42_;
	GString* _tmp43_;
	const gchar* _tmp44_;
	const gchar* _tmp45_;
	gchar* _tmp46_;
	gchar* _tmp47_;
	const gchar* _tmp48_;
	const gchar* _tmp49_;
	GString* _tmp55_;
	GString* _tmp56_;
	const gchar* _tmp57_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (path != NULL, FALSE);
	g_return_val_if_fail (config != NULL, FALSE);
	_tmp0_ = g_strdup ("");
	existing = _tmp0_;
	if (g_file_test (path, G_FILE_TEST_EXISTS)) {
		gchar* _tmp1_ = NULL;
		g_file_get_contents (path, &_tmp1_, NULL, &_inner_error0_);
		_g_free0 (existing);
		existing = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gboolean _tmp2_ = FALSE;
			g_propagate_error (error, _inner_error0_);
			_g_free0 (existing);
			return _tmp2_;
		}
	}
	_tmp3_ = g_strdup (WM_CONFIG_MODIFIER_LEGACY_BEGIN_MARKER);
	_tmp4_ = g_strdup (WM_CONFIG_MODIFIER_CURRENT_BEGIN_MARKER);
	_tmp5_ = g_new0 (gchar*, 2 + 1);
	_tmp5_[0] = _tmp3_;
	_tmp5_[1] = _tmp4_;
	begin_markers = _tmp5_;
	begin_markers_length1 = 2;
	_begin_markers_size_ = begin_markers_length1;
	_tmp6_ = g_strdup (WM_CONFIG_MODIFIER_LEGACY_END_MARKER);
	_tmp7_ = g_strdup (WM_CONFIG_MODIFIER_CURRENT_END_MARKER);
	_tmp8_ = g_new0 (gchar*, 2 + 1);
	_tmp8_[0] = _tmp6_;
	_tmp8_[1] = _tmp7_;
	end_markers = _tmp8_;
	end_markers_length1 = 2;
	_end_markers_size_ = end_markers_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp9_ = FALSE;
			_tmp9_ = TRUE;
			while (TRUE) {
				gchar** _tmp11_;
				gint _tmp11__length1;
				if (!_tmp9_) {
					gint _tmp10_;
					_tmp10_ = i;
					i = _tmp10_ + 1;
				}
				_tmp9_ = FALSE;
				_tmp11_ = begin_markers;
				_tmp11__length1 = begin_markers_length1;
				if (!(i < _tmp11__length1)) {
					break;
				}
				while (TRUE) {
					gint begin_pos = 0;
					const gchar* _tmp12_;
					gchar** _tmp13_;
					gint _tmp13__length1;
					const gchar* _tmp14_;
					gint end_pos = 0;
					const gchar* _tmp15_;
					gchar** _tmp16_;
					gint _tmp16__length1;
					const gchar* _tmp17_;
					gboolean _tmp18_ = FALSE;
					const gchar* _tmp19_;
					gchar* _tmp20_;
					gchar* _tmp21_;
					const gchar* _tmp22_;
					gchar** _tmp23_;
					gint _tmp23__length1;
					const gchar* _tmp24_;
					gint _tmp25_;
					gint _tmp26_;
					const gchar* _tmp27_;
					gint _tmp28_;
					gint _tmp29_;
					gchar* _tmp30_;
					gchar* _tmp31_;
					gchar* _tmp32_;
					_tmp12_ = existing;
					_tmp13_ = begin_markers;
					_tmp13__length1 = begin_markers_length1;
					_tmp14_ = _tmp13_[i];
					begin_pos = string_index_of (_tmp12_, _tmp14_, 0);
					_tmp15_ = existing;
					_tmp16_ = end_markers;
					_tmp16__length1 = end_markers_length1;
					_tmp17_ = _tmp16_[i];
					end_pos = string_index_of (_tmp15_, _tmp17_, 0);
					if (begin_pos < 0) {
						_tmp18_ = TRUE;
					} else {
						_tmp18_ = end_pos <= begin_pos;
					}
					if (_tmp18_) {
						break;
					}
					_tmp19_ = existing;
					_tmp20_ = string_slice (_tmp19_, (glong) 0, (glong) begin_pos);
					_tmp21_ = _tmp20_;
					_tmp22_ = existing;
					_tmp23_ = end_markers;
					_tmp23__length1 = end_markers_length1;
					_tmp24_ = _tmp23_[i];
					_tmp25_ = strlen (_tmp24_);
					_tmp26_ = _tmp25_;
					_tmp27_ = existing;
					_tmp28_ = strlen (_tmp27_);
					_tmp29_ = _tmp28_;
					_tmp30_ = string_slice (_tmp22_, (glong) (end_pos + _tmp26_), (glong) _tmp29_);
					_tmp31_ = _tmp30_;
					_tmp32_ = g_strconcat (_tmp21_, _tmp31_, NULL);
					_g_free0 (existing);
					existing = _tmp32_;
					_g_free0 (_tmp31_);
					_g_free0 (_tmp21_);
				}
			}
		}
	}
	_tmp33_ = existing;
	_tmp34_ = string_strip (_tmp33_);
	_g_free0 (existing);
	existing = _tmp34_;
	_tmp35_ = g_string_new ("");
	sb = _tmp35_;
	_tmp36_ = existing;
	_tmp37_ = strlen (_tmp36_);
	_tmp38_ = _tmp37_;
	if (_tmp38_ > 0) {
		GString* _tmp39_;
		const gchar* _tmp40_;
		GString* _tmp41_;
		_tmp39_ = sb;
		_tmp40_ = existing;
		g_string_append (_tmp39_, _tmp40_);
		_tmp41_ = sb;
		g_string_append (_tmp41_, "\n\n");
	}
	_tmp42_ = sb;
	g_string_append (_tmp42_, WM_CONFIG_MODIFIER_CURRENT_BEGIN_MARKER);
	_tmp43_ = sb;
	_tmp44_ = wm_config_modifier_xkb_config_get_layout (config);
	_tmp45_ = _tmp44_;
	_tmp46_ = g_strdup_printf ("export XKB_DEFAULT_LAYOUT=\"%s\"\n", _tmp45_);
	_tmp47_ = _tmp46_;
	g_string_append (_tmp43_, _tmp47_);
	_g_free0 (_tmp47_);
	_tmp48_ = wm_config_modifier_xkb_config_get_options (config);
	_tmp49_ = _tmp48_;
	if (g_strcmp0 (_tmp49_, "") != 0) {
		GString* _tmp50_;
		const gchar* _tmp51_;
		const gchar* _tmp52_;
		gchar* _tmp53_;
		gchar* _tmp54_;
		_tmp50_ = sb;
		_tmp51_ = wm_config_modifier_xkb_config_get_options (config);
		_tmp52_ = _tmp51_;
		_tmp53_ = g_strdup_printf ("export XKB_DEFAULT_OPTIONS=\"%s\"\n", _tmp52_);
		_tmp54_ = _tmp53_;
		g_string_append (_tmp50_, _tmp54_);
		_g_free0 (_tmp54_);
	}
	_tmp55_ = sb;
	g_string_append (_tmp55_, WM_CONFIG_MODIFIER_CURRENT_END_MARKER);
	_tmp56_ = sb;
	_tmp57_ = _tmp56_->str;
	g_file_set_contents (path, _tmp57_, (gssize) -1, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp58_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_g_string_free0 (sb);
		end_markers = (_vala_array_free (end_markers, end_markers_length1, (GDestroyNotify) g_free), NULL);
		begin_markers = (_vala_array_free (begin_markers, begin_markers_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (existing);
		return _tmp58_;
	}
	result = TRUE;
	_g_string_free0 (sb);
	end_markers = (_vala_array_free (end_markers, end_markers_length1, (GDestroyNotify) g_free), NULL);
	begin_markers = (_vala_array_free (begin_markers, begin_markers_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (existing);
	return result;
}

static gboolean
wm_config_modifier_apply_input_block (const gchar* path,
                                      const gchar* block_prefix,
                                      WMConfigModifierXKBConfig* config,
                                      GError** error)
{
	gchar* content = NULL;
	gchar* _tmp0_ = NULL;
	gchar** lines = NULL;
	const gchar* _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_;
	gint lines_length1;
	gint _lines_size_;
	GString* _result_ = NULL;
	GString* _tmp5_;
	gboolean found_block = FALSE;
	gchar** _tmp6_;
	gint _tmp6__length1;
	GString* _tmp34_;
	const gchar* _tmp35_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (path != NULL, FALSE);
	g_return_val_if_fail (block_prefix != NULL, FALSE);
	g_return_val_if_fail (config != NULL, FALSE);
	if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
		result = FALSE;
		return result;
	}
	g_file_get_contents (path, &_tmp0_, NULL, &_inner_error0_);
	_g_free0 (content);
	content = _tmp0_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp1_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_g_free0 (content);
		return _tmp1_;
	}
	_tmp2_ = content;
	_tmp4_ = _tmp3_ = g_strsplit (_tmp2_, "\n", 0);
	lines = _tmp4_;
	lines_length1 = _vala_array_length (_tmp3_);
	_lines_size_ = lines_length1;
	_tmp5_ = g_string_new ("");
	_result_ = _tmp5_;
	found_block = FALSE;
	_tmp6_ = lines;
	_tmp6__length1 = lines_length1;
	{
		gchar** line_collection = NULL;
		gint line_collection_length1 = 0;
		gint _line_collection_size_ = 0;
		gint line_it = 0;
		line_collection = _tmp6_;
		line_collection_length1 = _tmp6__length1;
		for (line_it = 0; line_it < line_collection_length1; line_it = line_it + 1) {
			gchar* _tmp7_;
			gchar* line = NULL;
			_tmp7_ = g_strdup (line_collection[line_it]);
			line = _tmp7_;
			{
				const gchar* _tmp8_;
				gchar* _tmp9_;
				gchar* _tmp10_;
				gboolean _tmp11_;
				_tmp8_ = line;
				_tmp9_ = string_strip (_tmp8_);
				_tmp10_ = _tmp9_;
				_tmp11_ = g_str_has_prefix (_tmp10_, block_prefix);
				_g_free0 (_tmp10_);
				if (_tmp11_) {
					GString* _tmp12_;
					const gchar* _tmp13_;
					const gchar* _tmp14_;
					const gchar* _tmp15_;
					const gchar* _tmp16_;
					gchar* _tmp17_;
					gchar* _tmp18_;
					found_block = TRUE;
					_tmp12_ = _result_;
					_tmp13_ = wm_config_modifier_xkb_config_get_layout (config);
					_tmp14_ = _tmp13_;
					_tmp15_ = wm_config_modifier_xkb_config_get_options (config);
					_tmp16_ = _tmp15_;
					_tmp17_ = g_strdup_printf ("%s { xkb_layout \"%s\" xkb_options \"%s\" }", block_prefix, _tmp14_, _tmp16_);
					_tmp18_ = _tmp17_;
					g_string_append (_tmp12_, _tmp18_);
					_g_free0 (_tmp18_);
				} else {
					gboolean _tmp19_ = FALSE;
					if (found_block) {
						const gchar* _tmp20_;
						gchar* _tmp21_;
						gchar* _tmp22_;
						_tmp20_ = line;
						_tmp21_ = string_strip (_tmp20_);
						_tmp22_ = _tmp21_;
						_tmp19_ = g_str_has_prefix (_tmp22_, "}");
						_g_free0 (_tmp22_);
					} else {
						_tmp19_ = FALSE;
					}
					if (_tmp19_) {
						found_block = FALSE;
						_g_free0 (line);
						continue;
					} else {
						if (!found_block) {
							GString* _tmp23_;
							const gchar* _tmp24_;
							gchar* _tmp25_;
							gchar* _tmp26_;
							_tmp23_ = _result_;
							_tmp24_ = line;
							_tmp25_ = g_strconcat (_tmp24_, "\n", NULL);
							_tmp26_ = _tmp25_;
							g_string_append (_tmp23_, _tmp26_);
							_g_free0 (_tmp26_);
						}
					}
				}
				_g_free0 (line);
			}
		}
	}
	if (!found_block) {
		GString* _tmp27_;
		const gchar* _tmp28_;
		const gchar* _tmp29_;
		const gchar* _tmp30_;
		const gchar* _tmp31_;
		gchar* _tmp32_;
		gchar* _tmp33_;
		_tmp27_ = _result_;
		_tmp28_ = wm_config_modifier_xkb_config_get_layout (config);
		_tmp29_ = _tmp28_;
		_tmp30_ = wm_config_modifier_xkb_config_get_options (config);
		_tmp31_ = _tmp30_;
		_tmp32_ = g_strdup_printf ("%s { xkb_layout \"%s\" xkb_options \"%s\" }", block_prefix, _tmp29_, _tmp31_);
		_tmp33_ = _tmp32_;
		g_string_append (_tmp27_, _tmp33_);
		_g_free0 (_tmp33_);
	}
	_tmp34_ = _result_;
	_tmp35_ = _tmp34_->str;
	g_file_set_contents (path, _tmp35_, (gssize) -1, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp36_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_g_string_free0 (_result_);
		lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (content);
		return _tmp36_;
	}
	result = TRUE;
	_g_string_free0 (_result_);
	lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (content);
	return result;
}

static gboolean
wm_config_modifier_apply_wayfire_section (const gchar* path,
                                          WMConfigModifierXKBConfig* config,
                                          GError** error)
{
	gchar* content = NULL;
	gchar* _tmp0_ = NULL;
	gchar** lines = NULL;
	const gchar* _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_;
	gint lines_length1;
	gint _lines_size_;
	GString* _result_ = NULL;
	GString* _tmp5_;
	gboolean in_input = FALSE;
	gchar** _tmp6_;
	gint _tmp6__length1;
	GString* _tmp40_;
	const gchar* _tmp41_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (path != NULL, FALSE);
	g_return_val_if_fail (config != NULL, FALSE);
	if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
		result = FALSE;
		return result;
	}
	g_file_get_contents (path, &_tmp0_, NULL, &_inner_error0_);
	_g_free0 (content);
	content = _tmp0_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp1_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_g_free0 (content);
		return _tmp1_;
	}
	_tmp2_ = content;
	_tmp4_ = _tmp3_ = g_strsplit (_tmp2_, "\n", 0);
	lines = _tmp4_;
	lines_length1 = _vala_array_length (_tmp3_);
	_lines_size_ = lines_length1;
	_tmp5_ = g_string_new ("");
	_result_ = _tmp5_;
	in_input = FALSE;
	_tmp6_ = lines;
	_tmp6__length1 = lines_length1;
	{
		gchar** line_collection = NULL;
		gint line_collection_length1 = 0;
		gint _line_collection_size_ = 0;
		gint line_it = 0;
		line_collection = _tmp6_;
		line_collection_length1 = _tmp6__length1;
		for (line_it = 0; line_it < line_collection_length1; line_it = line_it + 1) {
			gchar* _tmp7_;
			gchar* line = NULL;
			_tmp7_ = g_strdup (line_collection[line_it]);
			line = _tmp7_;
			{
				gchar* trimmed = NULL;
				const gchar* _tmp8_;
				gchar* _tmp9_;
				const gchar* _tmp10_;
				_tmp8_ = line;
				_tmp9_ = string_strip (_tmp8_);
				trimmed = _tmp9_;
				_tmp10_ = trimmed;
				if (g_strcmp0 (_tmp10_, "[input]") == 0) {
					GString* _tmp11_;
					const gchar* _tmp12_;
					gchar* _tmp13_;
					gchar* _tmp14_;
					_tmp11_ = _result_;
					_tmp12_ = line;
					_tmp13_ = g_strconcat (_tmp12_, "\n", NULL);
					_tmp14_ = _tmp13_;
					g_string_append (_tmp11_, _tmp14_);
					_g_free0 (_tmp14_);
					in_input = TRUE;
				} else {
					gboolean _tmp15_ = FALSE;
					if (in_input) {
						const gchar* _tmp16_;
						_tmp16_ = trimmed;
						_tmp15_ = g_str_has_prefix (_tmp16_, "[");
					} else {
						_tmp15_ = FALSE;
					}
					if (_tmp15_) {
						GString* _tmp17_;
						const gchar* _tmp18_;
						const gchar* _tmp19_;
						gchar* _tmp20_;
						gchar* _tmp21_;
						GString* _tmp22_;
						const gchar* _tmp23_;
						const gchar* _tmp24_;
						gchar* _tmp25_;
						gchar* _tmp26_;
						GString* _tmp27_;
						GString* _tmp28_;
						const gchar* _tmp29_;
						gchar* _tmp30_;
						gchar* _tmp31_;
						in_input = FALSE;
						_tmp17_ = _result_;
						_tmp18_ = wm_config_modifier_xkb_config_get_layout (config);
						_tmp19_ = _tmp18_;
						_tmp20_ = g_strdup_printf ("kb_layout = %s", _tmp19_);
						_tmp21_ = _tmp20_;
						g_string_append (_tmp17_, _tmp21_);
						_g_free0 (_tmp21_);
						_tmp22_ = _result_;
						_tmp23_ = wm_config_modifier_xkb_config_get_options (config);
						_tmp24_ = _tmp23_;
						_tmp25_ = g_strdup_printf ("kb_options = %s", _tmp24_);
						_tmp26_ = _tmp25_;
						g_string_append (_tmp22_, _tmp26_);
						_g_free0 (_tmp26_);
						_tmp27_ = _result_;
						g_string_append_c (_tmp27_, '\n');
						_tmp28_ = _result_;
						_tmp29_ = line;
						_tmp30_ = g_strconcat (_tmp29_, "\n", NULL);
						_tmp31_ = _tmp30_;
						g_string_append (_tmp28_, _tmp31_);
						_g_free0 (_tmp31_);
					} else {
						gboolean _tmp32_ = FALSE;
						if (in_input) {
							gboolean _tmp33_ = FALSE;
							const gchar* _tmp34_;
							_tmp34_ = trimmed;
							if (g_str_has_prefix (_tmp34_, "kb_layout")) {
								_tmp33_ = TRUE;
							} else {
								const gchar* _tmp35_;
								_tmp35_ = trimmed;
								_tmp33_ = g_str_has_prefix (_tmp35_, "kb_options");
							}
							_tmp32_ = _tmp33_;
						} else {
							_tmp32_ = FALSE;
						}
						if (_tmp32_) {
							_g_free0 (trimmed);
							_g_free0 (line);
							continue;
						} else {
							GString* _tmp36_;
							const gchar* _tmp37_;
							gchar* _tmp38_;
							gchar* _tmp39_;
							_tmp36_ = _result_;
							_tmp37_ = line;
							_tmp38_ = g_strconcat (_tmp37_, "\n", NULL);
							_tmp39_ = _tmp38_;
							g_string_append (_tmp36_, _tmp39_);
							_g_free0 (_tmp39_);
						}
					}
				}
				_g_free0 (trimmed);
				_g_free0 (line);
			}
		}
	}
	_tmp40_ = _result_;
	_tmp41_ = _tmp40_->str;
	g_file_set_contents (path, _tmp41_, (gssize) -1, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp42_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_g_string_free0 (_result_);
		lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (content);
		return _tmp42_;
	}
	result = TRUE;
	_g_string_free0 (_result_);
	lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (content);
	return result;
}

static gboolean
wm_config_modifier_apply_hyprland_env (const gchar* path,
                                       WMConfigModifierXKBConfig* config,
                                       GError** error)
{
	gchar* content = NULL;
	gchar* _tmp0_ = NULL;
	gchar** lines = NULL;
	const gchar* _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_;
	gint lines_length1;
	gint _lines_size_;
	GString* _result_ = NULL;
	GString* _tmp5_;
	gboolean layout_found = FALSE;
	gboolean options_found = FALSE;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gboolean _tmp35_ = FALSE;
	GString* _tmp43_;
	const gchar* _tmp44_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (path != NULL, FALSE);
	g_return_val_if_fail (config != NULL, FALSE);
	if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
		result = FALSE;
		return result;
	}
	g_file_get_contents (path, &_tmp0_, NULL, &_inner_error0_);
	_g_free0 (content);
	content = _tmp0_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp1_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_g_free0 (content);
		return _tmp1_;
	}
	_tmp2_ = content;
	_tmp4_ = _tmp3_ = g_strsplit (_tmp2_, "\n", 0);
	lines = _tmp4_;
	lines_length1 = _vala_array_length (_tmp3_);
	_lines_size_ = lines_length1;
	_tmp5_ = g_string_new ("");
	_result_ = _tmp5_;
	layout_found = FALSE;
	options_found = FALSE;
	_tmp6_ = lines;
	_tmp6__length1 = lines_length1;
	{
		gchar** line_collection = NULL;
		gint line_collection_length1 = 0;
		gint _line_collection_size_ = 0;
		gint line_it = 0;
		line_collection = _tmp6_;
		line_collection_length1 = _tmp6__length1;
		for (line_it = 0; line_it < line_collection_length1; line_it = line_it + 1) {
			gchar* _tmp7_;
			gchar* line = NULL;
			_tmp7_ = g_strdup (line_collection[line_it]);
			line = _tmp7_;
			{
				gchar* trimmed = NULL;
				const gchar* _tmp8_;
				gchar* _tmp9_;
				gboolean _tmp10_ = FALSE;
				const gchar* _tmp11_;
				_tmp8_ = line;
				_tmp9_ = string_strip (_tmp8_);
				trimmed = _tmp9_;
				_tmp11_ = trimmed;
				if (g_str_has_prefix (_tmp11_, "env = XKB_DEFAULT_LAYOUT")) {
					_tmp10_ = TRUE;
				} else {
					const gchar* _tmp12_;
					_tmp12_ = trimmed;
					_tmp10_ = g_str_has_prefix (_tmp12_, "env=XKB_DEFAULT_LAYOUT");
				}
				if (_tmp10_) {
					GString* _tmp13_;
					const gchar* _tmp14_;
					const gchar* _tmp15_;
					gchar* _tmp16_;
					gchar* _tmp17_;
					_tmp13_ = _result_;
					_tmp14_ = wm_config_modifier_xkb_config_get_layout (config);
					_tmp15_ = _tmp14_;
					_tmp16_ = g_strdup_printf ("env = XKB_DEFAULT_LAYOUT,%s", _tmp15_);
					_tmp17_ = _tmp16_;
					g_string_append (_tmp13_, _tmp17_);
					_g_free0 (_tmp17_);
					layout_found = TRUE;
				} else {
					gboolean _tmp18_ = FALSE;
					const gchar* _tmp19_;
					_tmp19_ = trimmed;
					if (g_str_has_prefix (_tmp19_, "env = XKB_DEFAULT_OPTIONS")) {
						_tmp18_ = TRUE;
					} else {
						const gchar* _tmp20_;
						_tmp20_ = trimmed;
						_tmp18_ = g_str_has_prefix (_tmp20_, "env=XKB_DEFAULT_OPTIONS");
					}
					if (_tmp18_) {
						GString* _tmp21_;
						const gchar* _tmp22_;
						const gchar* _tmp23_;
						gchar* _tmp24_;
						gchar* _tmp25_;
						_tmp21_ = _result_;
						_tmp22_ = wm_config_modifier_xkb_config_get_options (config);
						_tmp23_ = _tmp22_;
						_tmp24_ = g_strdup_printf ("env = XKB_DEFAULT_OPTIONS,%s", _tmp23_);
						_tmp25_ = _tmp24_;
						g_string_append (_tmp21_, _tmp25_);
						_g_free0 (_tmp25_);
						options_found = TRUE;
					} else {
						GString* _tmp26_;
						const gchar* _tmp27_;
						gchar* _tmp28_;
						gchar* _tmp29_;
						_tmp26_ = _result_;
						_tmp27_ = line;
						_tmp28_ = g_strconcat (_tmp27_, "\n", NULL);
						_tmp29_ = _tmp28_;
						g_string_append (_tmp26_, _tmp29_);
						_g_free0 (_tmp29_);
					}
				}
				_g_free0 (trimmed);
				_g_free0 (line);
			}
		}
	}
	if (!layout_found) {
		GString* _tmp30_;
		const gchar* _tmp31_;
		const gchar* _tmp32_;
		gchar* _tmp33_;
		gchar* _tmp34_;
		_tmp30_ = _result_;
		_tmp31_ = wm_config_modifier_xkb_config_get_layout (config);
		_tmp32_ = _tmp31_;
		_tmp33_ = g_strdup_printf ("env = XKB_DEFAULT_LAYOUT,%s", _tmp32_);
		_tmp34_ = _tmp33_;
		g_string_append (_tmp30_, _tmp34_);
		_g_free0 (_tmp34_);
	}
	if (!options_found) {
		const gchar* _tmp36_;
		const gchar* _tmp37_;
		_tmp36_ = wm_config_modifier_xkb_config_get_options (config);
		_tmp37_ = _tmp36_;
		_tmp35_ = g_strcmp0 (_tmp37_, "") != 0;
	} else {
		_tmp35_ = FALSE;
	}
	if (_tmp35_) {
		GString* _tmp38_;
		const gchar* _tmp39_;
		const gchar* _tmp40_;
		gchar* _tmp41_;
		gchar* _tmp42_;
		_tmp38_ = _result_;
		_tmp39_ = wm_config_modifier_xkb_config_get_options (config);
		_tmp40_ = _tmp39_;
		_tmp41_ = g_strdup_printf ("env = XKB_DEFAULT_OPTIONS,%s", _tmp40_);
		_tmp42_ = _tmp41_;
		g_string_append (_tmp38_, _tmp42_);
		_g_free0 (_tmp42_);
	}
	_tmp43_ = _result_;
	_tmp44_ = _tmp43_->str;
	g_file_set_contents (path, _tmp44_, (gssize) -1, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp45_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_g_string_free0 (_result_);
		lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (content);
		return _tmp45_;
	}
	result = TRUE;
	_g_string_free0 (_result_);
	lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (content);
	return result;
}

gboolean
wm_config_modifier_test_apply_env_exports (const gchar* path,
                                           WMConfigModifierXKBConfig* config,
                                           GError** error)
{
	gboolean _tmp0_ = FALSE;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (path != NULL, FALSE);
	g_return_val_if_fail (config != NULL, FALSE);
	_tmp0_ = wm_config_modifier_apply_env_exports (path, config, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp1_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	}
	result = _tmp0_;
	return result;
}

WMConfigModifier*
wm_config_modifier_construct (GType object_type)
{
	WMConfigModifier * self = NULL;
	self = (WMConfigModifier*) g_object_new (object_type, NULL);
	return self;
}

WMConfigModifier*
wm_config_modifier_new (void)
{
	return wm_config_modifier_construct (TYPE_WM_CONFIG_MODIFIER);
}

static inline gpointer
wm_config_modifier_xkb_config_get_instance_private (WMConfigModifierXKBConfig* self)
{
	return G_STRUCT_MEMBER_P (self, WMConfigModifierXKBConfig_private_offset);
}

gchar*
wm_config_modifier_xkb_config_to_env_string (WMConfigModifierXKBConfig* self)
{
	GString* sb = NULL;
	GString* _tmp0_;
	GString* _tmp1_;
	GString* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp8_;
	GString* _tmp13_;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_string_new ("");
	sb = _tmp0_;
	_tmp1_ = sb;
	g_string_append (_tmp1_, "XKB_DEFAULT_LAYOUT=");
	_tmp2_ = sb;
	_tmp3_ = self->priv->_layout;
	g_string_append (_tmp2_, _tmp3_);
	_tmp4_ = self->priv->_variant;
	if (g_strcmp0 (_tmp4_, "") != 0) {
		GString* _tmp5_;
		GString* _tmp6_;
		const gchar* _tmp7_;
		_tmp5_ = sb;
		g_string_append (_tmp5_, ",");
		_tmp6_ = sb;
		_tmp7_ = self->priv->_variant;
		g_string_append (_tmp6_, _tmp7_);
	}
	_tmp8_ = self->priv->_options;
	if (g_strcmp0 (_tmp8_, "") != 0) {
		GString* _tmp9_;
		GString* _tmp10_;
		GString* _tmp11_;
		const gchar* _tmp12_;
		_tmp9_ = sb;
		g_string_append_c (_tmp9_, '\n');
		_tmp10_ = sb;
		g_string_append (_tmp10_, "XKB_DEFAULT_OPTIONS=");
		_tmp11_ = sb;
		_tmp12_ = self->priv->_options;
		g_string_append (_tmp11_, _tmp12_);
	}
	_tmp13_ = sb;
	_tmp14_ = _tmp13_->str;
	_tmp15_ = g_strdup (_tmp14_);
	result = _tmp15_;
	_g_string_free0 (sb);
	return result;
}

WMConfigModifierXKBConfig*
wm_config_modifier_xkb_config_construct (GType object_type)
{
	WMConfigModifierXKBConfig* self = NULL;
	self = (WMConfigModifierXKBConfig*) g_type_create_instance (object_type);
	return self;
}

WMConfigModifierXKBConfig*
wm_config_modifier_xkb_config_new (void)
{
	return wm_config_modifier_xkb_config_construct (WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG);
}

const gchar*
wm_config_modifier_xkb_config_get_layout (WMConfigModifierXKBConfig* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_layout;
	result = _tmp0_;
	return result;
}

void
wm_config_modifier_xkb_config_set_layout (WMConfigModifierXKBConfig* self,
                                          const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_layout);
	self->priv->_layout = _tmp0_;
}

const gchar*
wm_config_modifier_xkb_config_get_variant (WMConfigModifierXKBConfig* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_variant;
	result = _tmp0_;
	return result;
}

void
wm_config_modifier_xkb_config_set_variant (WMConfigModifierXKBConfig* self,
                                           const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_variant);
	self->priv->_variant = _tmp0_;
}

const gchar*
wm_config_modifier_xkb_config_get_options (WMConfigModifierXKBConfig* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_options;
	result = _tmp0_;
	return result;
}

void
wm_config_modifier_xkb_config_set_options (WMConfigModifierXKBConfig* self,
                                           const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_options);
	self->priv->_options = _tmp0_;
}

static void
wm_config_modifier_value_xkb_config_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
wm_config_modifier_value_xkb_config_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		wm_config_modifier_xkb_config_unref (value->data[0].v_pointer);
	}
}

static void
wm_config_modifier_value_xkb_config_copy_value (const GValue* src_value,
                                                GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = wm_config_modifier_xkb_config_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
wm_config_modifier_value_xkb_config_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
wm_config_modifier_value_xkb_config_collect_value (GValue* value,
                                                   guint n_collect_values,
                                                   GTypeCValue* collect_values,
                                                   guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		WMConfigModifierXKBConfig * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = wm_config_modifier_xkb_config_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
wm_config_modifier_value_xkb_config_lcopy_value (const GValue* value,
                                                 guint n_collect_values,
                                                 GTypeCValue* collect_values,
                                                 guint collect_flags)
{
	WMConfigModifierXKBConfig ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = wm_config_modifier_xkb_config_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
wm_config_modifier_param_spec_xkb_config (const gchar* name,
                                          const gchar* nick,
                                          const gchar* blurb,
                                          GType object_type,
                                          GParamFlags flags)
{
	WMConfigModifierParamSpecXKBConfig* spec;
	g_return_val_if_fail (g_type_is_a (object_type, WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
wm_config_modifier_value_get_xkb_config (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG), NULL);
	return value->data[0].v_pointer;
}

void
wm_config_modifier_value_set_xkb_config (GValue* value,
                                         gpointer v_object)
{
	WMConfigModifierXKBConfig * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		wm_config_modifier_xkb_config_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		wm_config_modifier_xkb_config_unref (old);
	}
}

void
wm_config_modifier_value_take_xkb_config (GValue* value,
                                          gpointer v_object)
{
	WMConfigModifierXKBConfig * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		wm_config_modifier_xkb_config_unref (old);
	}
}

static void
wm_config_modifier_xkb_config_class_init (WMConfigModifierXKBConfigClass * klass,
                                          gpointer klass_data)
{
	wm_config_modifier_xkb_config_parent_class = g_type_class_peek_parent (klass);
	((WMConfigModifierXKBConfigClass *) klass)->finalize = wm_config_modifier_xkb_config_finalize;
	g_type_class_adjust_private_offset (klass, &WMConfigModifierXKBConfig_private_offset);
}

static void
wm_config_modifier_xkb_config_instance_init (WMConfigModifierXKBConfig * self,
                                             gpointer klass)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	self->priv = wm_config_modifier_xkb_config_get_instance_private (self);
	_tmp0_ = g_strdup ("us");
	self->priv->_layout = _tmp0_;
	_tmp1_ = g_strdup ("");
	self->priv->_variant = _tmp1_;
	_tmp2_ = g_strdup ("");
	self->priv->_options = _tmp2_;
	self->ref_count = 1;
}

static void
wm_config_modifier_xkb_config_finalize (WMConfigModifierXKBConfig * obj)
{
	WMConfigModifierXKBConfig * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WM_CONFIG_MODIFIER_TYPE_XKB_CONFIG, WMConfigModifierXKBConfig);
	g_signal_handlers_destroy (self);
	_g_free0 (self->priv->_layout);
	_g_free0 (self->priv->_variant);
	_g_free0 (self->priv->_options);
}

static GType
wm_config_modifier_xkb_config_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { wm_config_modifier_value_xkb_config_init, wm_config_modifier_value_xkb_config_free_value, wm_config_modifier_value_xkb_config_copy_value, wm_config_modifier_value_xkb_config_peek_pointer, "p", wm_config_modifier_value_xkb_config_collect_value, "p", wm_config_modifier_value_xkb_config_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (WMConfigModifierXKBConfigClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) wm_config_modifier_xkb_config_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WMConfigModifierXKBConfig), 0, (GInstanceInitFunc) wm_config_modifier_xkb_config_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType wm_config_modifier_xkb_config_type_id;
	wm_config_modifier_xkb_config_type_id = g_type_register_fundamental (g_type_fundamental_next (), "WMConfigModifierXKBConfig", &g_define_type_info, &g_define_type_fundamental_info, 0);
	WMConfigModifierXKBConfig_private_offset = g_type_add_instance_private (wm_config_modifier_xkb_config_type_id, sizeof (WMConfigModifierXKBConfigPrivate));
	return wm_config_modifier_xkb_config_type_id;
}

GType
wm_config_modifier_xkb_config_get_type (void)
{
	static volatile gsize wm_config_modifier_xkb_config_type_id__once = 0;
	if (g_once_init_enter (&wm_config_modifier_xkb_config_type_id__once)) {
		GType wm_config_modifier_xkb_config_type_id;
		wm_config_modifier_xkb_config_type_id = wm_config_modifier_xkb_config_get_type_once ();
		g_once_init_leave (&wm_config_modifier_xkb_config_type_id__once, wm_config_modifier_xkb_config_type_id);
	}
	return wm_config_modifier_xkb_config_type_id__once;
}

gpointer
wm_config_modifier_xkb_config_ref (gpointer instance)
{
	WMConfigModifierXKBConfig * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
wm_config_modifier_xkb_config_unref (gpointer instance)
{
	WMConfigModifierXKBConfig * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		WM_CONFIG_MODIFIER_XKB_CONFIG_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
wm_config_modifier_class_init (WMConfigModifierClass * klass,
                               gpointer klass_data)
{
	wm_config_modifier_parent_class = g_type_class_peek_parent (klass);
}

static void
wm_config_modifier_instance_init (WMConfigModifier * self,
                                  gpointer klass)
{
}

static GType
wm_config_modifier_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WMConfigModifierClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) wm_config_modifier_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WMConfigModifier), 0, (GInstanceInitFunc) wm_config_modifier_instance_init, NULL };
	GType wm_config_modifier_type_id;
	wm_config_modifier_type_id = g_type_register_static (G_TYPE_OBJECT, "WMConfigModifier", &g_define_type_info, 0);
	return wm_config_modifier_type_id;
}

GType
wm_config_modifier_get_type (void)
{
	static volatile gsize wm_config_modifier_type_id__once = 0;
	if (g_once_init_enter (&wm_config_modifier_type_id__once)) {
		GType wm_config_modifier_type_id;
		wm_config_modifier_type_id = wm_config_modifier_get_type_once ();
		g_once_init_leave (&wm_config_modifier_type_id__once, wm_config_modifier_type_id);
	}
	return wm_config_modifier_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

