/* backlightUtil.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from backlightUtil.vala, do not modify */

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
#include <float.h>
#include <math.h>
#include <gobject/gvaluecollector.h>

#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 SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_BACKLIGHT_UTIL (sway_notification_center_widgets_backlight_util_get_type ())
#define SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_BACKLIGHT_UTIL, SwayNotificationCenterWidgetsBacklightUtil))
#define SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_BACKLIGHT_UTIL, SwayNotificationCenterWidgetsBacklightUtilClass))
#define SWAY_NOTIFICATION_CENTER_WIDGETS_IS_BACKLIGHT_UTIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_BACKLIGHT_UTIL))
#define SWAY_NOTIFICATION_CENTER_WIDGETS_IS_BACKLIGHT_UTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_BACKLIGHT_UTIL))
#define SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_BACKLIGHT_UTIL, SwayNotificationCenterWidgetsBacklightUtilClass))

typedef struct _SwayNotificationCenterWidgetsBacklightUtil SwayNotificationCenterWidgetsBacklightUtil;
typedef struct _SwayNotificationCenterWidgetsBacklightUtilClass SwayNotificationCenterWidgetsBacklightUtilClass;
typedef struct _SwayNotificationCenterWidgetsBacklightUtilPrivate SwayNotificationCenterWidgetsBacklightUtilPrivate;

#define SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_TYPE_LOGIN1 (sway_notification_center_widgets_backlight_util_login1_get_type ())
#define SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_LOGIN1(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_TYPE_LOGIN1, SwayNotificationCenterWidgetsBacklightUtilLogin1))
#define SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_IS_LOGIN1(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_TYPE_LOGIN1))
#define SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_LOGIN1_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_TYPE_LOGIN1, SwayNotificationCenterWidgetsBacklightUtilLogin1Iface))

typedef struct _SwayNotificationCenterWidgetsBacklightUtilLogin1 SwayNotificationCenterWidgetsBacklightUtilLogin1;
typedef struct _SwayNotificationCenterWidgetsBacklightUtilLogin1Iface SwayNotificationCenterWidgetsBacklightUtilLogin1Iface;

#define SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_TYPE_LOGIN1_PROXY (sway_notification_center_widgets_backlight_util_login1_proxy_get_type ())
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _sway_notification_center_widgets_backlight_util_unref0(var) ((var == NULL) ? NULL : (var = (sway_notification_center_widgets_backlight_util_unref (var), NULL)))
typedef struct _SwayNotificationCenterWidgetsBacklightUtilSetBrightnessData SwayNotificationCenterWidgetsBacklightUtilSetBrightnessData;
typedef GDBusProxy SwayNotificationCenterWidgetsBacklightUtilLogin1Proxy;
typedef GDBusProxyClass SwayNotificationCenterWidgetsBacklightUtilLogin1ProxyClass;
typedef struct _SwayNotificationCenterWidgetsBacklightUtilLogin1SetBrightnessReadyData SwayNotificationCenterWidgetsBacklightUtilLogin1SetBrightnessReadyData;
typedef struct _SwayNotificationCenterWidgetsParamSpecBacklightUtil SwayNotificationCenterWidgetsParamSpecBacklightUtil;
enum  {
	SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_BRIGHTNESS_CHANGE_SIGNAL,
	SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_NUM_SIGNALS
};
static guint sway_notification_center_widgets_backlight_util_signals[SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_NUM_SIGNALS] = {0};

struct _SwayNotificationCenterWidgetsBacklightUtil {
	GTypeInstance parent_instance;
	volatile int ref_count;
	SwayNotificationCenterWidgetsBacklightUtilPrivate * priv;
};

struct _SwayNotificationCenterWidgetsBacklightUtilClass {
	GTypeClass parent_class;
	void (*finalize) (SwayNotificationCenterWidgetsBacklightUtil *self);
};

struct _SwayNotificationCenterWidgetsBacklightUtilLogin1Iface {
	GTypeInterface parent_iface;
	void (*set_brightness) (SwayNotificationCenterWidgetsBacklightUtilLogin1* self, const gchar* subsystem, const gchar* name, guint32 brightness, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*set_brightness_finish) (SwayNotificationCenterWidgetsBacklightUtilLogin1* self, GAsyncResult* _res_, GError** error);
};

struct _SwayNotificationCenterWidgetsBacklightUtilPrivate {
	gchar* path_current;
	gchar* path_max;
	GFile* fd;
	GFileMonitor* monitor;
	gint max;
	SwayNotificationCenterWidgetsBacklightUtilLogin1* login1;
	gchar* device;
	gchar* subsystem;
};

struct _SwayNotificationCenterWidgetsBacklightUtilSetBrightnessData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	SwayNotificationCenterWidgetsBacklightUtil* self;
	gfloat percent;
	const gchar* _tmp0_;
	gint actual;
	SwayNotificationCenterWidgetsBacklightUtilLogin1* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	SwayNotificationCenterWidgetsBacklightUtilLogin1* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
};

struct _SwayNotificationCenterWidgetsBacklightUtilLogin1SetBrightnessReadyData {
	GDBusMethodInvocation* _invocation_;
	gchar* subsystem;
	gchar* name;
	guint32 brightness;
};

struct _SwayNotificationCenterWidgetsParamSpecBacklightUtil {
	GParamSpec parent_instance;
};

static gint SwayNotificationCenterWidgetsBacklightUtil_private_offset;
static gpointer sway_notification_center_widgets_backlight_util_parent_class = NULL;

VALA_EXTERN gpointer sway_notification_center_widgets_backlight_util_ref (gpointer instance);
VALA_EXTERN void sway_notification_center_widgets_backlight_util_unref (gpointer instance);
VALA_EXTERN GParamSpec* sway_notification_center_widgets_param_spec_backlight_util (const gchar* name,
                                                                        const gchar* nick,
                                                                        const gchar* blurb,
                                                                        GType object_type,
                                                                        GParamFlags flags);
VALA_EXTERN void sway_notification_center_widgets_value_set_backlight_util (GValue* value,
                                                                gpointer v_object);
VALA_EXTERN void sway_notification_center_widgets_value_take_backlight_util (GValue* value,
                                                                 gpointer v_object);
VALA_EXTERN gpointer sway_notification_center_widgets_value_get_backlight_util (const GValue* value);
VALA_EXTERN GType sway_notification_center_widgets_backlight_util_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SwayNotificationCenterWidgetsBacklightUtil, sway_notification_center_widgets_backlight_util_unref)
VALA_EXTERN GType sway_notification_center_widgets_backlight_util_login1_proxy_get_type (void) G_GNUC_CONST ;
static guint sway_notification_center_widgets_backlight_util_login1_register_object (void* object,
                                                                              GDBusConnection* connection,
                                                                              const gchar* path,
                                                                              GError** error);
static GType sway_notification_center_widgets_backlight_util_login1_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SwayNotificationCenterWidgetsBacklightUtilLogin1, g_object_unref)
VALA_EXTERN SwayNotificationCenterWidgetsBacklightUtil* sway_notification_center_widgets_backlight_util_new (const gchar* s,
                                                                                                 const gchar* d);
VALA_EXTERN SwayNotificationCenterWidgetsBacklightUtil* sway_notification_center_widgets_backlight_util_construct (GType object_type,
                                                                                                       const gchar* s,
                                                                                                       const gchar* d);
static void sway_notification_center_widgets_backlight_util_set_max_value (SwayNotificationCenterWidgetsBacklightUtil* self);
VALA_EXTERN void sway_notification_center_widgets_backlight_util_close (SwayNotificationCenterWidgetsBacklightUtil* self);
VALA_EXTERN void sway_notification_center_widgets_backlight_util_start (SwayNotificationCenterWidgetsBacklightUtil* self);
static void sway_notification_center_widgets_backlight_util_get_brightness (SwayNotificationCenterWidgetsBacklightUtil* self);
static void sway_notification_center_widgets_backlight_util_connect_monitor (SwayNotificationCenterWidgetsBacklightUtil* self);
static void ___lambda85_ (SwayNotificationCenterWidgetsBacklightUtil* self,
                   GFile* src,
                   GFile* dest,
                   GFileMonitorEvent event);
static void ____lambda85__g_file_monitor_changed (GFileMonitor* _sender,
                                           GFile* file,
                                           GFile* other_file,
                                           GFileMonitorEvent event_type,
                                           gpointer self);
static void sway_notification_center_widgets_backlight_util_set_brightness_data_free (gpointer _data);
VALA_EXTERN void sway_notification_center_widgets_backlight_util_set_brightness (SwayNotificationCenterWidgetsBacklightUtil* self,
                                                                     gfloat percent,
                                                                     GAsyncReadyCallback _callback_,
                                                                     gpointer _user_data_);
VALA_EXTERN void sway_notification_center_widgets_backlight_util_set_brightness_finish (SwayNotificationCenterWidgetsBacklightUtil* self,
                                                                            GAsyncResult* _res_);
static gboolean sway_notification_center_widgets_backlight_util_set_brightness_co (SwayNotificationCenterWidgetsBacklightUtilSetBrightnessData* _data_);
static gint sway_notification_center_widgets_backlight_util_calc_actual (SwayNotificationCenterWidgetsBacklightUtil* self,
                                                                  gfloat val);
static void sway_notification_center_widgets_backlight_util_login1_set_brightness (SwayNotificationCenterWidgetsBacklightUtilLogin1* self,
                                                                            const gchar* subsystem,
                                                                            const gchar* name,
                                                                            guint32 brightness,
                                                                            GAsyncReadyCallback _callback_,
                                                                            gpointer _user_data_);
static void sway_notification_center_widgets_backlight_util_login1_set_brightness_finish (SwayNotificationCenterWidgetsBacklightUtilLogin1* self,
                                                                                   GAsyncResult* _res_,
                                                                                   GError** error);
static gint sway_notification_center_widgets_backlight_util_calc_percent (SwayNotificationCenterWidgetsBacklightUtil* self,
                                                                   gint val);
VALA_EXTERN gint sway_notification_center_widgets_backlight_util_get_max_value (SwayNotificationCenterWidgetsBacklightUtil* self);
static GType sway_notification_center_widgets_backlight_util_login1_get_type_once (void);
static void sway_notification_center_widgets_backlight_util_login1_proxy_g_signal (GDBusProxy* proxy,
                                                                            const gchar* sender_name,
                                                                            const gchar* signal_name,
                                                                            GVariant* parameters);
static void _vala_g_async_ready_callback (GObject *source_object,
                                   GAsyncResult *res,
                                   void *user_data);
static void sway_notification_center_widgets_backlight_util_login1_proxy_set_brightness_async (SwayNotificationCenterWidgetsBacklightUtilLogin1* self,
                                                                                        const gchar* subsystem,
                                                                                        const gchar* name,
                                                                                        guint32 brightness,
                                                                                        GAsyncReadyCallback _callback_,
                                                                                        gpointer _user_data_);
static void sway_notification_center_widgets_backlight_util_login1_proxy_set_brightness_finish (SwayNotificationCenterWidgetsBacklightUtilLogin1* self,
                                                                                         GAsyncResult* _res_,
                                                                                         GError** error);
static void sway_notification_center_widgets_backlight_util_login1_proxy_sway_notification_center_widgets_backlight_util_login1_interface_init (SwayNotificationCenterWidgetsBacklightUtilLogin1Iface* iface);
static void _dbus_sway_notification_center_widgets_backlight_util_login1_set_brightness (SwayNotificationCenterWidgetsBacklightUtilLogin1* self,
                                                                                  GVariant* _parameters_,
                                                                                  GDBusMethodInvocation* invocation);
static void _dbus_sway_notification_center_widgets_backlight_util_login1_set_brightness_ready (GObject * source_object,
                                                                                        GAsyncResult * _res_,
                                                                                        gpointer _user_data_);
static void sway_notification_center_widgets_backlight_util_login1_dbus_interface_method_call (GDBusConnection* connection,
                                                                                        const gchar* sender,
                                                                                        const gchar* object_path,
                                                                                        const gchar* interface_name,
                                                                                        const gchar* method_name,
                                                                                        GVariant* parameters,
                                                                                        GDBusMethodInvocation* invocation,
                                                                                        gpointer user_data);
static GVariant* sway_notification_center_widgets_backlight_util_login1_dbus_interface_get_property (GDBusConnection* connection,
                                                                                              const gchar* sender,
                                                                                              const gchar* object_path,
                                                                                              const gchar* interface_name,
                                                                                              const gchar* property_name,
                                                                                              GError** error,
                                                                                              gpointer user_data);
static gboolean sway_notification_center_widgets_backlight_util_login1_dbus_interface_set_property (GDBusConnection* connection,
                                                                                             const gchar* sender,
                                                                                             const gchar* object_path,
                                                                                             const gchar* interface_name,
                                                                                             const gchar* property_name,
                                                                                             GVariant* value,
                                                                                             GError** error,
                                                                                             gpointer user_data);
static void _sway_notification_center_widgets_backlight_util_login1_unregister_object (gpointer user_data);
static void sway_notification_center_widgets_backlight_util_finalize (SwayNotificationCenterWidgetsBacklightUtil * obj);
static GType sway_notification_center_widgets_backlight_util_get_type_once (void);

static const GDBusArgInfo _sway_notification_center_widgets_backlight_util_login1_dbus_arg_info_set_brightness_subsystem = {-1, "subsystem", "s", NULL};
static const GDBusArgInfo _sway_notification_center_widgets_backlight_util_login1_dbus_arg_info_set_brightness_name = {-1, "name", "s", NULL};
static const GDBusArgInfo _sway_notification_center_widgets_backlight_util_login1_dbus_arg_info_set_brightness_brightness = {-1, "brightness", "u", NULL};
static const GDBusArgInfo * const _sway_notification_center_widgets_backlight_util_login1_dbus_arg_info_set_brightness_in[] = {&_sway_notification_center_widgets_backlight_util_login1_dbus_arg_info_set_brightness_subsystem, &_sway_notification_center_widgets_backlight_util_login1_dbus_arg_info_set_brightness_name, &_sway_notification_center_widgets_backlight_util_login1_dbus_arg_info_set_brightness_brightness, NULL};
static const GDBusArgInfo * const _sway_notification_center_widgets_backlight_util_login1_dbus_arg_info_set_brightness_out[] = {NULL};
static const GDBusMethodInfo _sway_notification_center_widgets_backlight_util_login1_dbus_method_info_set_brightness = {-1, "SetBrightness", (GDBusArgInfo **) (&_sway_notification_center_widgets_backlight_util_login1_dbus_arg_info_set_brightness_in), (GDBusArgInfo **) (&_sway_notification_center_widgets_backlight_util_login1_dbus_arg_info_set_brightness_out), NULL};
static const GDBusMethodInfo * const _sway_notification_center_widgets_backlight_util_login1_dbus_method_info[] = {&_sway_notification_center_widgets_backlight_util_login1_dbus_method_info_set_brightness, NULL};
static const GDBusSignalInfo * const _sway_notification_center_widgets_backlight_util_login1_dbus_signal_info[] = {NULL};
static const GDBusPropertyInfo * const _sway_notification_center_widgets_backlight_util_login1_dbus_property_info[] = {NULL};
static const GDBusInterfaceInfo _sway_notification_center_widgets_backlight_util_login1_dbus_interface_info = {-1, "org.freedesktop.login1.Session", (GDBusMethodInfo **) (&_sway_notification_center_widgets_backlight_util_login1_dbus_method_info), (GDBusSignalInfo **) (&_sway_notification_center_widgets_backlight_util_login1_dbus_signal_info), (GDBusPropertyInfo **) (&_sway_notification_center_widgets_backlight_util_login1_dbus_property_info), NULL};
static const GDBusInterfaceVTable _sway_notification_center_widgets_backlight_util_login1_dbus_interface_vtable = {sway_notification_center_widgets_backlight_util_login1_dbus_interface_method_call, sway_notification_center_widgets_backlight_util_login1_dbus_interface_get_property, sway_notification_center_widgets_backlight_util_login1_dbus_interface_set_property};

static inline gpointer
sway_notification_center_widgets_backlight_util_get_instance_private (SwayNotificationCenterWidgetsBacklightUtil* self)
{
	return G_STRUCT_MEMBER_P (self, SwayNotificationCenterWidgetsBacklightUtil_private_offset);
}

SwayNotificationCenterWidgetsBacklightUtil*
sway_notification_center_widgets_backlight_util_construct (GType object_type,
                                                           const gchar* s,
                                                           const gchar* d)
{
	SwayNotificationCenterWidgetsBacklightUtil* self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	GFile* _tmp9_;
	GFile* _tmp10_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (s != NULL, NULL);
	g_return_val_if_fail (d != NULL, NULL);
	self = (SwayNotificationCenterWidgetsBacklightUtil*) g_type_create_instance (object_type);
	_tmp0_ = g_strdup (s);
	_g_free0 (self->priv->subsystem);
	self->priv->subsystem = _tmp0_;
	_tmp1_ = g_strdup (d);
	_g_free0 (self->priv->device);
	self->priv->device = _tmp1_;
	_tmp2_ = self->priv->subsystem;
	_tmp3_ = self->priv->device;
	_tmp4_ = g_build_path (G_DIR_SEPARATOR_S, "/sys", "class", _tmp2_, _tmp3_, "brightness", NULL);
	_g_free0 (self->priv->path_current);
	self->priv->path_current = _tmp4_;
	_tmp5_ = self->priv->subsystem;
	_tmp6_ = self->priv->device;
	_tmp7_ = g_build_path (G_DIR_SEPARATOR_S, "/sys", "class", _tmp5_, _tmp6_, "max_brightness", NULL);
	_g_free0 (self->priv->path_max);
	self->priv->path_max = _tmp7_;
	_tmp8_ = self->priv->path_current;
	_tmp9_ = g_file_new_for_path (_tmp8_);
	_g_object_unref0 (self->priv->fd);
	self->priv->fd = _tmp9_;
	_tmp10_ = self->priv->fd;
	if (g_file_query_exists (_tmp10_, NULL)) {
		sway_notification_center_widgets_backlight_util_set_max_value (self);
		{
			GFileMonitor* _tmp11_ = NULL;
			GFile* _tmp12_;
			GFileMonitor* _tmp13_;
			GFileMonitor* _tmp14_;
			_tmp12_ = self->priv->fd;
			_tmp13_ = g_file_monitor (_tmp12_, G_FILE_MONITOR_NONE, NULL, &_inner_error0_);
			_tmp11_ = _tmp13_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp14_ = _tmp11_;
			_tmp11_ = NULL;
			_g_object_unref0 (self->priv->monitor);
			self->priv->monitor = _tmp14_;
			_g_object_unref0 (_tmp11_);
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* e = NULL;
			GError* _tmp15_;
			const gchar* _tmp16_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp15_ = e;
			_tmp16_ = _tmp15_->message;
			g_critical ("backlightUtil.vala:37: Error %s\n", _tmp16_);
			_g_error_free0 (e);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			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;
		}
	} else {
		const gchar* _tmp17_;
		g_signal_emit (self, sway_notification_center_widgets_backlight_util_signals[SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_BRIGHTNESS_CHANGE_SIGNAL], 0, -1);
		_tmp17_ = self->priv->path_current;
		g_warning ("backlightUtil.vala:41: Could not find device %s\n", _tmp17_);
		sway_notification_center_widgets_backlight_util_close (self);
	}
	{
		SwayNotificationCenterWidgetsBacklightUtilLogin1* _tmp18_ = NULL;
		SwayNotificationCenterWidgetsBacklightUtilLogin1* _tmp19_;
		SwayNotificationCenterWidgetsBacklightUtilLogin1* _tmp20_;
		_tmp19_ = (SwayNotificationCenterWidgetsBacklightUtilLogin1*) g_initable_new (SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_TYPE_LOGIN1_PROXY, NULL, &_inner_error0_, "g-flags", 0, "g-name", "org.freedesktop.login1", "g-bus-type", G_BUS_TYPE_SYSTEM, "g-object-path", "/org/freedesktop/login1/session/auto", "g-interface-name", "org.freedesktop.login1.Session", NULL);
		_tmp18_ = (SwayNotificationCenterWidgetsBacklightUtilLogin1*) _tmp19_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch1_g_error;
		}
		_tmp20_ = _tmp18_;
		_tmp18_ = NULL;
		_g_object_unref0 (self->priv->login1);
		self->priv->login1 = _tmp20_;
		_g_object_unref0 (_tmp18_);
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e = NULL;
		GError* _tmp21_;
		const gchar* _tmp22_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp21_ = e;
		_tmp22_ = _tmp21_->message;
		g_critical ("backlightUtil.vala:51: Error %s\n", _tmp22_);
		_g_error_free0 (e);
	}
	__finally1:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		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;
	}
	return self;
}

SwayNotificationCenterWidgetsBacklightUtil*
sway_notification_center_widgets_backlight_util_new (const gchar* s,
                                                     const gchar* d)
{
	return sway_notification_center_widgets_backlight_util_construct (SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_BACKLIGHT_UTIL, s, d);
}

void
sway_notification_center_widgets_backlight_util_start (SwayNotificationCenterWidgetsBacklightUtil* self)
{
	GFile* _tmp0_;
	g_return_if_fail (SWAY_NOTIFICATION_CENTER_WIDGETS_IS_BACKLIGHT_UTIL (self));
	_tmp0_ = self->priv->fd;
	if (g_file_query_exists (_tmp0_, NULL)) {
		sway_notification_center_widgets_backlight_util_get_brightness (self);
		sway_notification_center_widgets_backlight_util_connect_monitor (self);
	} else {
		const gchar* _tmp1_;
		g_signal_emit (self, sway_notification_center_widgets_backlight_util_signals[SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_BRIGHTNESS_CHANGE_SIGNAL], 0, -1);
		_tmp1_ = self->priv->path_current;
		g_critical ("backlightUtil.vala:63: Could not find device %s\n", _tmp1_);
		sway_notification_center_widgets_backlight_util_close (self);
	}
}

static void
___lambda85_ (SwayNotificationCenterWidgetsBacklightUtil* self,
              GFile* src,
              GFile* dest,
              GFileMonitorEvent event)
{
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (src, g_file_get_type ()));
	g_return_if_fail ((dest == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (dest, g_file_get_type ()));
	sway_notification_center_widgets_backlight_util_get_brightness (self);
}

static void
____lambda85__g_file_monitor_changed (GFileMonitor* _sender,
                                      GFile* file,
                                      GFile* other_file,
                                      GFileMonitorEvent event_type,
                                      gpointer self)
{
	___lambda85_ ((SwayNotificationCenterWidgetsBacklightUtil*) self, file, other_file, event_type);
}

static void
sway_notification_center_widgets_backlight_util_connect_monitor (SwayNotificationCenterWidgetsBacklightUtil* self)
{
	GFileMonitor* _tmp0_;
	g_return_if_fail (SWAY_NOTIFICATION_CENTER_WIDGETS_IS_BACKLIGHT_UTIL (self));
	_tmp0_ = self->priv->monitor;
	if (_tmp0_ != NULL) {
		GFileMonitor* _tmp1_;
		_tmp1_ = self->priv->monitor;
		g_signal_connect (_tmp1_, "changed", (GCallback) ____lambda85__g_file_monitor_changed, self);
	}
}

void
sway_notification_center_widgets_backlight_util_close (SwayNotificationCenterWidgetsBacklightUtil* self)
{
	GFileMonitor* _tmp0_;
	g_return_if_fail (SWAY_NOTIFICATION_CENTER_WIDGETS_IS_BACKLIGHT_UTIL (self));
	_tmp0_ = self->priv->monitor;
	if (_tmp0_ != NULL) {
		GFileMonitor* _tmp1_;
		_tmp1_ = self->priv->monitor;
		g_file_monitor_cancel (_tmp1_);
	}
}

static void
sway_notification_center_widgets_backlight_util_set_brightness_data_free (gpointer _data)
{
	SwayNotificationCenterWidgetsBacklightUtilSetBrightnessData* _data_;
	_data_ = _data;
	_sway_notification_center_widgets_backlight_util_unref0 (_data_->self);
	g_slice_free (SwayNotificationCenterWidgetsBacklightUtilSetBrightnessData, _data_);
}

static gpointer
_sway_notification_center_widgets_backlight_util_ref0 (gpointer self)
{
	return self ? sway_notification_center_widgets_backlight_util_ref (self) : NULL;
}

void
sway_notification_center_widgets_backlight_util_set_brightness (SwayNotificationCenterWidgetsBacklightUtil* self,
                                                                gfloat percent,
                                                                GAsyncReadyCallback _callback_,
                                                                gpointer _user_data_)
{
	SwayNotificationCenterWidgetsBacklightUtilSetBrightnessData* _data_;
	SwayNotificationCenterWidgetsBacklightUtil* _tmp0_;
	g_return_if_fail (SWAY_NOTIFICATION_CENTER_WIDGETS_IS_BACKLIGHT_UTIL (self));
	_data_ = g_slice_new0 (SwayNotificationCenterWidgetsBacklightUtilSetBrightnessData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, sway_notification_center_widgets_backlight_util_set_brightness_data_free);
	_tmp0_ = _sway_notification_center_widgets_backlight_util_ref0 (self);
	_data_->self = _tmp0_;
	_data_->percent = percent;
	sway_notification_center_widgets_backlight_util_set_brightness_co (_data_);
}

void
sway_notification_center_widgets_backlight_util_set_brightness_finish (SwayNotificationCenterWidgetsBacklightUtil* self,
                                                                       GAsyncResult* _res_)
{
	SwayNotificationCenterWidgetsBacklightUtilSetBrightnessData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static gboolean
sway_notification_center_widgets_backlight_util_set_brightness_co (SwayNotificationCenterWidgetsBacklightUtilSetBrightnessData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	sway_notification_center_widgets_backlight_util_close (_data_->self);
	_data_->_tmp0_ = _data_->self->priv->subsystem;
	if (g_strcmp0 (_data_->_tmp0_, "backlight") == 0) {
		_data_->actual = sway_notification_center_widgets_backlight_util_calc_actual (_data_->self, _data_->percent);
		_data_->_tmp1_ = _data_->self->priv->login1;
		_data_->_tmp2_ = _data_->self->priv->subsystem;
		_data_->_tmp3_ = _data_->self->priv->device;
		sway_notification_center_widgets_backlight_util_login1_set_brightness (_data_->_tmp1_, _data_->_tmp2_, _data_->_tmp3_, (guint32) _data_->actual, NULL, NULL);
	} else {
		_data_->_tmp4_ = _data_->self->priv->login1;
		_data_->_tmp5_ = _data_->self->priv->subsystem;
		_data_->_tmp6_ = _data_->self->priv->device;
		sway_notification_center_widgets_backlight_util_login1_set_brightness (_data_->_tmp4_, _data_->_tmp5_, _data_->_tmp6_, (guint32) _data_->percent, NULL, NULL);
	}
	sway_notification_center_widgets_backlight_util_connect_monitor (_data_->self);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
sway_notification_center_widgets_backlight_util_get_brightness (SwayNotificationCenterWidgetsBacklightUtil* self)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (SWAY_NOTIFICATION_CENTER_WIDGETS_IS_BACKLIGHT_UTIL (self));
	{
		GFileInputStream* _tmp0_ = NULL;
		GFile* _tmp1_;
		GFileInputStream* _tmp2_;
		GDataInputStream* dis = NULL;
		GDataInputStream* _tmp3_;
		gchar* data = NULL;
		GDataInputStream* _tmp4_;
		gchar* _tmp5_;
		const gchar* _tmp6_;
		_tmp1_ = self->priv->fd;
		_tmp2_ = g_file_read (_tmp1_, NULL, &_inner_error0_);
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp3_ = g_data_input_stream_new (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, g_input_stream_get_type (), GInputStream));
		if (_tmp3_) {
			g_object_set_data ((GObject *) _tmp3_, "vala-creation-function", "SwayNotificationCenter.Widgets.BacklightUtil.get_brightness");
		}
		dis = _tmp3_;
		_tmp4_ = dis;
		_tmp5_ = g_data_input_stream_read_line (_tmp4_, NULL, NULL, &_inner_error0_);
		data = _tmp5_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (dis);
			_g_object_unref0 (_tmp0_);
			goto __catch0_g_error;
		}
		_tmp6_ = self->priv->subsystem;
		if (g_strcmp0 (_tmp6_, "backlight") == 0) {
			gint val = 0;
			const gchar* _tmp7_;
			_tmp7_ = data;
			val = sway_notification_center_widgets_backlight_util_calc_percent (self, atoi (_tmp7_));
			g_signal_emit (self, sway_notification_center_widgets_backlight_util_signals[SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_BRIGHTNESS_CHANGE_SIGNAL], 0, val);
		} else {
			const gchar* _tmp8_;
			_tmp8_ = data;
			g_signal_emit (self, sway_notification_center_widgets_backlight_util_signals[SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_BRIGHTNESS_CHANGE_SIGNAL], 0, atoi (_tmp8_));
		}
		_g_free0 (data);
		_g_object_unref0 (dis);
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp9_;
		const gchar* _tmp10_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp9_ = e;
		_tmp10_ = _tmp9_->message;
		g_critical ("backlightUtil.vala:106: Error %s\n", _tmp10_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		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;
	}
}

static void
sway_notification_center_widgets_backlight_util_set_max_value (SwayNotificationCenterWidgetsBacklightUtil* self)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (SWAY_NOTIFICATION_CENTER_WIDGETS_IS_BACKLIGHT_UTIL (self));
	{
		GFile* fd_max = NULL;
		const gchar* _tmp0_;
		GFile* _tmp1_;
		GFileInputStream* _tmp2_ = NULL;
		GFile* _tmp3_;
		GFileInputStream* _tmp4_;
		GDataInputStream* dis_max = NULL;
		GDataInputStream* _tmp5_;
		gchar* data = NULL;
		GDataInputStream* _tmp6_;
		gchar* _tmp7_;
		const gchar* _tmp8_;
		_tmp0_ = self->priv->path_max;
		_tmp1_ = g_file_new_for_path (_tmp0_);
		fd_max = _tmp1_;
		_tmp3_ = fd_max;
		_tmp4_ = g_file_read (_tmp3_, NULL, &_inner_error0_);
		_tmp2_ = _tmp4_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (fd_max);
			goto __catch0_g_error;
		}
		_tmp5_ = g_data_input_stream_new (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, g_input_stream_get_type (), GInputStream));
		if (_tmp5_) {
			g_object_set_data ((GObject *) _tmp5_, "vala-creation-function", "SwayNotificationCenter.Widgets.BacklightUtil.set_max_value");
		}
		dis_max = _tmp5_;
		_tmp6_ = dis_max;
		_tmp7_ = g_data_input_stream_read_line (_tmp6_, NULL, NULL, &_inner_error0_);
		data = _tmp7_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (dis_max);
			_g_object_unref0 (_tmp2_);
			_g_object_unref0 (fd_max);
			goto __catch0_g_error;
		}
		_tmp8_ = data;
		self->priv->max = atoi (_tmp8_);
		_g_free0 (data);
		_g_object_unref0 (dis_max);
		_g_object_unref0 (_tmp2_);
		_g_object_unref0 (fd_max);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp9_;
		const gchar* _tmp10_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp9_ = e;
		_tmp10_ = _tmp9_->message;
		g_critical ("backlightUtil.vala:117: Error %s\n", _tmp10_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		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;
	}
}

static gint
sway_notification_center_widgets_backlight_util_calc_percent (SwayNotificationCenterWidgetsBacklightUtil* self,
                                                              gint val)
{
	gint result;
	g_return_val_if_fail (SWAY_NOTIFICATION_CENTER_WIDGETS_IS_BACKLIGHT_UTIL (self), 0);
	result = (gint) round ((val * 100.0) / self->priv->max);
	return result;
}

static gint
sway_notification_center_widgets_backlight_util_calc_actual (SwayNotificationCenterWidgetsBacklightUtil* self,
                                                             gfloat val)
{
	gint result;
	g_return_val_if_fail (SWAY_NOTIFICATION_CENTER_WIDGETS_IS_BACKLIGHT_UTIL (self), 0);
	result = (gint) round ((gdouble) ((val * self->priv->max) / 100));
	return result;
}

gint
sway_notification_center_widgets_backlight_util_get_max_value (SwayNotificationCenterWidgetsBacklightUtil* self)
{
	gint result;
	g_return_val_if_fail (SWAY_NOTIFICATION_CENTER_WIDGETS_IS_BACKLIGHT_UTIL (self), 0);
	result = self->priv->max;
	return result;
}

void
sway_notification_center_widgets_backlight_util_login1_set_brightness (SwayNotificationCenterWidgetsBacklightUtilLogin1* self,
                                                                       const gchar* subsystem,
                                                                       const gchar* name,
                                                                       guint32 brightness,
                                                                       GAsyncReadyCallback _callback_,
                                                                       gpointer _user_data_)
{
	SwayNotificationCenterWidgetsBacklightUtilLogin1Iface* _iface_;
	_iface_ = SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_LOGIN1_GET_INTERFACE (self);
	if (_iface_->set_brightness) {
		_iface_->set_brightness (self, subsystem, name, brightness, _callback_, _user_data_);
	}
}

void
sway_notification_center_widgets_backlight_util_login1_set_brightness_finish (SwayNotificationCenterWidgetsBacklightUtilLogin1* self,
                                                                              GAsyncResult* _res_,
                                                                              GError** error)
{
	SwayNotificationCenterWidgetsBacklightUtilLogin1Iface* _iface_;
	_iface_ = SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_LOGIN1_GET_INTERFACE (self);
	if (_iface_->set_brightness_finish) {
		_iface_->set_brightness_finish (self, _res_, error);
	}
}

static void
sway_notification_center_widgets_backlight_util_login1_default_init (SwayNotificationCenterWidgetsBacklightUtilLogin1Iface * iface,
                                                                     gpointer iface_data)
{
}

 G_GNUC_NO_INLINE static GType
sway_notification_center_widgets_backlight_util_login1_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SwayNotificationCenterWidgetsBacklightUtilLogin1Iface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) sway_notification_center_widgets_backlight_util_login1_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType sway_notification_center_widgets_backlight_util_login1_type_id;
	sway_notification_center_widgets_backlight_util_login1_type_id = g_type_register_static (G_TYPE_INTERFACE, "SwayNotificationCenterWidgetsBacklightUtilLogin1", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (sway_notification_center_widgets_backlight_util_login1_type_id, G_TYPE_OBJECT);
	g_type_set_qdata (sway_notification_center_widgets_backlight_util_login1_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) sway_notification_center_widgets_backlight_util_login1_proxy_get_type);
	g_type_set_qdata (sway_notification_center_widgets_backlight_util_login1_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.freedesktop.login1.Session");
	g_type_set_qdata (sway_notification_center_widgets_backlight_util_login1_type_id, g_quark_from_static_string ("vala-dbus-interface-info"), (void*) (&_sway_notification_center_widgets_backlight_util_login1_dbus_interface_info));
	g_type_set_qdata (sway_notification_center_widgets_backlight_util_login1_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) sway_notification_center_widgets_backlight_util_login1_register_object);
	return sway_notification_center_widgets_backlight_util_login1_type_id;
}

static GType
sway_notification_center_widgets_backlight_util_login1_get_type (void)
{
	static gsize sway_notification_center_widgets_backlight_util_login1_type_id__once = 0;
	if (g_once_init_enter (&sway_notification_center_widgets_backlight_util_login1_type_id__once)) {
		GType sway_notification_center_widgets_backlight_util_login1_type_id;
		sway_notification_center_widgets_backlight_util_login1_type_id = sway_notification_center_widgets_backlight_util_login1_get_type_once ();
		g_once_init_leave (&sway_notification_center_widgets_backlight_util_login1_type_id__once, sway_notification_center_widgets_backlight_util_login1_type_id);
	}
	return sway_notification_center_widgets_backlight_util_login1_type_id__once;
}

G_DEFINE_TYPE_EXTENDED (SwayNotificationCenterWidgetsBacklightUtilLogin1Proxy, sway_notification_center_widgets_backlight_util_login1_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT_INTERFACE (SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_TYPE_LOGIN1, sway_notification_center_widgets_backlight_util_login1_proxy_sway_notification_center_widgets_backlight_util_login1_interface_init) )
static void
sway_notification_center_widgets_backlight_util_login1_proxy_class_init (SwayNotificationCenterWidgetsBacklightUtilLogin1ProxyClass* klass)
{
	G_DBUS_PROXY_CLASS (klass)->g_signal = sway_notification_center_widgets_backlight_util_login1_proxy_g_signal;
}

static void
sway_notification_center_widgets_backlight_util_login1_proxy_g_signal (GDBusProxy* proxy,
                                                                       const gchar* sender_name,
                                                                       const gchar* signal_name,
                                                                       GVariant* parameters)
{
}

static void
sway_notification_center_widgets_backlight_util_login1_proxy_init (SwayNotificationCenterWidgetsBacklightUtilLogin1Proxy* self)
{
	g_dbus_proxy_set_interface_info (G_DBUS_PROXY (self), (GDBusInterfaceInfo *) (&_sway_notification_center_widgets_backlight_util_login1_dbus_interface_info));
}

static void
_vala_g_async_ready_callback (GObject *source_object,
                              GAsyncResult *res,
                              void *user_data)
{
	g_task_return_pointer (user_data, g_object_ref (res), g_object_unref);
	g_object_unref (user_data);
}

static void
sway_notification_center_widgets_backlight_util_login1_proxy_set_brightness_async (SwayNotificationCenterWidgetsBacklightUtilLogin1* self,
                                                                                   const gchar* subsystem,
                                                                                   const gchar* name,
                                                                                   guint32 brightness,
                                                                                   GAsyncReadyCallback _callback_,
                                                                                   gpointer _user_data_)
{
	GDBusMessage *_message;
	GVariant *_arguments;
	GVariantBuilder _arguments_builder;
	_message = g_dbus_message_new_method_call (g_dbus_proxy_get_name ((GDBusProxy *) self), g_dbus_proxy_get_object_path ((GDBusProxy *) self), "org.freedesktop.login1.Session", "SetBrightness");
	g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_string (subsystem));
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_string (name));
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_uint32 (brightness));
	_arguments = g_variant_builder_end (&_arguments_builder);
	g_dbus_message_set_body (_message, _arguments);
	if (_callback_ != NULL) {
		g_dbus_connection_send_message_with_reply (g_dbus_proxy_get_connection ((GDBusProxy *) self), _message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, g_dbus_proxy_get_default_timeout ((GDBusProxy *) self), NULL, NULL, _vala_g_async_ready_callback, g_task_new ((GObject *) self, NULL, _callback_, _user_data_));
	} else {
		g_dbus_message_set_flags (_message, G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED);
		g_dbus_connection_send_message (g_dbus_proxy_get_connection ((GDBusProxy *) self), _message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	}
	g_object_unref (_message);
}

static void
sway_notification_center_widgets_backlight_util_login1_proxy_set_brightness_finish (SwayNotificationCenterWidgetsBacklightUtilLogin1* self,
                                                                                    GAsyncResult* _res_,
                                                                                    GError** error)
{
	GAsyncResult *_inner_res;
	GDBusMessage *_reply_message;
	_inner_res = g_task_propagate_pointer ((GTask *) _res_, NULL);
	_reply_message = g_dbus_connection_send_message_with_reply_finish (g_dbus_proxy_get_connection ((GDBusProxy *) self), _inner_res, error);
	g_object_unref (_inner_res);
	if (!_reply_message) {
		return;
	}
	if (g_dbus_message_to_gerror (_reply_message, error)) {
		g_object_unref (_reply_message);
		return;
	}
	g_object_unref (_reply_message);
}

static void
sway_notification_center_widgets_backlight_util_login1_proxy_sway_notification_center_widgets_backlight_util_login1_interface_init (SwayNotificationCenterWidgetsBacklightUtilLogin1Iface* iface)
{
	iface->set_brightness = sway_notification_center_widgets_backlight_util_login1_proxy_set_brightness_async;
	iface->set_brightness_finish = sway_notification_center_widgets_backlight_util_login1_proxy_set_brightness_finish;
}

static void
_dbus_sway_notification_center_widgets_backlight_util_login1_set_brightness (SwayNotificationCenterWidgetsBacklightUtilLogin1* self,
                                                                             GVariant* _parameters_,
                                                                             GDBusMethodInvocation* invocation)
{
	GVariantIter _arguments_iter;
	SwayNotificationCenterWidgetsBacklightUtilLogin1SetBrightnessReadyData* _ready_data;
	GVariant* _tmp0_;
	GVariant* _tmp1_;
	GVariant* _tmp2_;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	_ready_data = g_slice_new0 (SwayNotificationCenterWidgetsBacklightUtilLogin1SetBrightnessReadyData);
	_ready_data->_invocation_ = invocation;
	_tmp0_ = g_variant_iter_next_value (&_arguments_iter);
	_ready_data->subsystem = g_variant_dup_string (_tmp0_, NULL);
	g_variant_unref (_tmp0_);
	_tmp1_ = g_variant_iter_next_value (&_arguments_iter);
	_ready_data->name = g_variant_dup_string (_tmp1_, NULL);
	g_variant_unref (_tmp1_);
	_tmp2_ = g_variant_iter_next_value (&_arguments_iter);
	_ready_data->brightness = g_variant_get_uint32 (_tmp2_);
	g_variant_unref (_tmp2_);
	sway_notification_center_widgets_backlight_util_login1_set_brightness (self, _ready_data->subsystem, _ready_data->name, _ready_data->brightness, (GAsyncReadyCallback) _dbus_sway_notification_center_widgets_backlight_util_login1_set_brightness_ready, _ready_data);
	_error:
	;
}

static void
_dbus_sway_notification_center_widgets_backlight_util_login1_set_brightness_ready (GObject * source_object,
                                                                                   GAsyncResult * _res_,
                                                                                   gpointer _user_data_)
{
	SwayNotificationCenterWidgetsBacklightUtilLogin1SetBrightnessReadyData* _ready_data;
	GDBusMethodInvocation* invocation;
	GError* error = NULL;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	_ready_data = _user_data_;
	invocation = _ready_data->_invocation_;
	sway_notification_center_widgets_backlight_util_login1_set_brightness_finish ((SwayNotificationCenterWidgetsBacklightUtilLogin1*) source_object, _res_, &error);
	if (error) {
		g_dbus_method_invocation_take_error (invocation, error);
		goto _error;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
	_error:
	_g_free0 (_ready_data->subsystem);
	_g_free0 (_ready_data->name);
	g_slice_free (SwayNotificationCenterWidgetsBacklightUtilLogin1SetBrightnessReadyData, _ready_data);
}

static void
sway_notification_center_widgets_backlight_util_login1_dbus_interface_method_call (GDBusConnection* connection,
                                                                                   const gchar* sender,
                                                                                   const gchar* object_path,
                                                                                   const gchar* interface_name,
                                                                                   const gchar* method_name,
                                                                                   GVariant* parameters,
                                                                                   GDBusMethodInvocation* invocation,
                                                                                   gpointer user_data)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	if (strcmp (method_name, "SetBrightness") == 0) {
		_dbus_sway_notification_center_widgets_backlight_util_login1_set_brightness (object, parameters, invocation);
	} else {
		g_object_unref (invocation);
	}
}

static GVariant*
sway_notification_center_widgets_backlight_util_login1_dbus_interface_get_property (GDBusConnection* connection,
                                                                                    const gchar* sender,
                                                                                    const gchar* object_path,
                                                                                    const gchar* interface_name,
                                                                                    const gchar* property_name,
                                                                                    GError** error,
                                                                                    gpointer user_data)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	return NULL;
}

static gboolean
sway_notification_center_widgets_backlight_util_login1_dbus_interface_set_property (GDBusConnection* connection,
                                                                                    const gchar* sender,
                                                                                    const gchar* object_path,
                                                                                    const gchar* interface_name,
                                                                                    const gchar* property_name,
                                                                                    GVariant* value,
                                                                                    GError** error,
                                                                                    gpointer user_data)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	return FALSE;
}

static guint
sway_notification_center_widgets_backlight_util_login1_register_object (gpointer object,
                                                                        GDBusConnection* connection,
                                                                        const gchar* path,
                                                                        GError** error)
{
	guint result;
	gpointer *data;
	data = g_new (gpointer, 3);
	data[0] = g_object_ref (object);
	data[1] = g_object_ref (connection);
	data[2] = g_strdup (path);
	result = g_dbus_connection_register_object (connection, path, (GDBusInterfaceInfo *) (&_sway_notification_center_widgets_backlight_util_login1_dbus_interface_info), &_sway_notification_center_widgets_backlight_util_login1_dbus_interface_vtable, data, _sway_notification_center_widgets_backlight_util_login1_unregister_object, error);
	if (!result) {
		return 0;
	}
	return result;
}

static void
_sway_notification_center_widgets_backlight_util_login1_unregister_object (gpointer user_data)
{
	gpointer* data;
	data = user_data;
	g_object_unref (data[0]);
	g_object_unref (data[1]);
	g_free (data[2]);
	g_free (data);
}

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

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

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

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

static gchar*
sway_notification_center_widgets_value_backlight_util_collect_value (GValue* value,
                                                                     guint n_collect_values,
                                                                     GTypeCValue* collect_values,
                                                                     guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		SwayNotificationCenterWidgetsBacklightUtil * 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 = sway_notification_center_widgets_backlight_util_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
sway_notification_center_widgets_value_backlight_util_lcopy_value (const GValue* value,
                                                                   guint n_collect_values,
                                                                   GTypeCValue* collect_values,
                                                                   guint collect_flags)
{
	SwayNotificationCenterWidgetsBacklightUtil ** 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 = sway_notification_center_widgets_backlight_util_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
sway_notification_center_widgets_param_spec_backlight_util (const gchar* name,
                                                            const gchar* nick,
                                                            const gchar* blurb,
                                                            GType object_type,
                                                            GParamFlags flags)
{
	SwayNotificationCenterWidgetsParamSpecBacklightUtil* spec;
	g_return_val_if_fail (g_type_is_a (object_type, SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_BACKLIGHT_UTIL), 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
sway_notification_center_widgets_value_get_backlight_util (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_BACKLIGHT_UTIL), NULL);
	return value->data[0].v_pointer;
}

void
sway_notification_center_widgets_value_set_backlight_util (GValue* value,
                                                           gpointer v_object)
{
	SwayNotificationCenterWidgetsBacklightUtil * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_BACKLIGHT_UTIL));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_BACKLIGHT_UTIL));
		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;
		sway_notification_center_widgets_backlight_util_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		sway_notification_center_widgets_backlight_util_unref (old);
	}
}

void
sway_notification_center_widgets_value_take_backlight_util (GValue* value,
                                                            gpointer v_object)
{
	SwayNotificationCenterWidgetsBacklightUtil * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_BACKLIGHT_UTIL));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_BACKLIGHT_UTIL));
		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) {
		sway_notification_center_widgets_backlight_util_unref (old);
	}
}

static void
sway_notification_center_widgets_backlight_util_class_init (SwayNotificationCenterWidgetsBacklightUtilClass * klass,
                                                            gpointer klass_data)
{
	sway_notification_center_widgets_backlight_util_parent_class = g_type_class_peek_parent (klass);
	((SwayNotificationCenterWidgetsBacklightUtilClass *) klass)->finalize = sway_notification_center_widgets_backlight_util_finalize;
	g_type_class_adjust_private_offset (klass, &SwayNotificationCenterWidgetsBacklightUtil_private_offset);
	sway_notification_center_widgets_backlight_util_signals[SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_BRIGHTNESS_CHANGE_SIGNAL] = g_signal_new ("brightness-change", SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_BACKLIGHT_UTIL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
}

static void
sway_notification_center_widgets_backlight_util_instance_init (SwayNotificationCenterWidgetsBacklightUtil * self,
                                                               gpointer klass)
{
	self->priv = sway_notification_center_widgets_backlight_util_get_instance_private (self);
	self->priv->monitor = NULL;
	self->ref_count = 1;
}

static void
sway_notification_center_widgets_backlight_util_finalize (SwayNotificationCenterWidgetsBacklightUtil * obj)
{
	SwayNotificationCenterWidgetsBacklightUtil * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SWAY_NOTIFICATION_CENTER_WIDGETS_TYPE_BACKLIGHT_UTIL, SwayNotificationCenterWidgetsBacklightUtil);
	g_signal_handlers_destroy (self);
	_g_free0 (self->priv->path_current);
	_g_free0 (self->priv->path_max);
	_g_object_unref0 (self->priv->fd);
	_g_object_unref0 (self->priv->monitor);
	_g_object_unref0 (self->priv->login1);
	_g_free0 (self->priv->device);
	_g_free0 (self->priv->subsystem);
}

 G_GNUC_NO_INLINE static GType
sway_notification_center_widgets_backlight_util_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { sway_notification_center_widgets_value_backlight_util_init, sway_notification_center_widgets_value_backlight_util_free_value, sway_notification_center_widgets_value_backlight_util_copy_value, sway_notification_center_widgets_value_backlight_util_peek_pointer, "p", sway_notification_center_widgets_value_backlight_util_collect_value, "p", sway_notification_center_widgets_value_backlight_util_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (SwayNotificationCenterWidgetsBacklightUtilClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) sway_notification_center_widgets_backlight_util_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SwayNotificationCenterWidgetsBacklightUtil), 0, (GInstanceInitFunc) sway_notification_center_widgets_backlight_util_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 sway_notification_center_widgets_backlight_util_type_id;
	sway_notification_center_widgets_backlight_util_type_id = g_type_register_fundamental (g_type_fundamental_next (), "SwayNotificationCenterWidgetsBacklightUtil", &g_define_type_info, &g_define_type_fundamental_info, 0);
	SwayNotificationCenterWidgetsBacklightUtil_private_offset = g_type_add_instance_private (sway_notification_center_widgets_backlight_util_type_id, sizeof (SwayNotificationCenterWidgetsBacklightUtilPrivate));
	return sway_notification_center_widgets_backlight_util_type_id;
}

GType
sway_notification_center_widgets_backlight_util_get_type (void)
{
	static gsize sway_notification_center_widgets_backlight_util_type_id__once = 0;
	if (g_once_init_enter (&sway_notification_center_widgets_backlight_util_type_id__once)) {
		GType sway_notification_center_widgets_backlight_util_type_id;
		sway_notification_center_widgets_backlight_util_type_id = sway_notification_center_widgets_backlight_util_get_type_once ();
		g_once_init_leave (&sway_notification_center_widgets_backlight_util_type_id__once, sway_notification_center_widgets_backlight_util_type_id);
	}
	return sway_notification_center_widgets_backlight_util_type_id__once;
}

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

void
sway_notification_center_widgets_backlight_util_unref (gpointer instance)
{
	SwayNotificationCenterWidgetsBacklightUtil * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		SWAY_NOTIFICATION_CENTER_WIDGETS_BACKLIGHT_UTIL_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

