[Xfce4-commits] [xfce/xfce4-power-manager] 10/17: Install property for restoring original brightness switch value
noreply at xfce.org
noreply at xfce.org
Wed Jul 23 22:03:00 CEST 2014
This is an automated email from the git hooks/post-receive script.
hjudt pushed a commit to branch master
in repository xfce/xfce4-power-manager.
commit 3b82d8435d2fd1cee02f0cdc64738da616b45f97
Author: Harald Judt <h.judt at gmx.at>
Date: Wed Jul 23 11:55:20 2014 +0200
Install property for restoring original brightness switch value
On most machines, especially those using the video module backlight, the kernel
will already have hooked up the brightness keys. If the user wants to use
xfce4-power-manager to control the keys, then we need to disable this module
setting to avoid conflicts like brightness lowered or raised twice on key
presses.
Of course, it would be nice if the power manager restored the original setting
when it gives control back to the kernel or on exit. To be able to do this,
it needs to remember the value.
It is best to do this in a xfconf setting so it survives crashes. This way,
power manager has a chance of restoring the original setting even after a
crash, so that the user will not have to fix it manually.
There are three possible settings, read from
/sys/module/video/parameters/brightness_switch_enabled:
1 = kernel brightness switch setting is enabled (value 'Y')
0 = kernel brightness switch setting is disabled (value 'N')
-1 = kernel brightness switch unavailable or could not be read
---
src/xfpm-backlight.c | 17 +++++++++++++++++
src/xfpm-config.h | 1 +
src/xfpm-xfconf.c | 3 ++-
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/src/xfpm-backlight.c b/src/xfpm-backlight.c
index a2cd0f1..ce36307 100644
--- a/src/xfpm-backlight.c
+++ b/src/xfpm-backlight.c
@@ -82,6 +82,7 @@ struct XfpmBacklightPrivate
gint32 max_level;
gint brightness_switch;
+ gint brightness_switch_save;
gboolean dimmed;
gboolean block;
@@ -91,6 +92,7 @@ enum
{
PROP_0,
PROP_BRIGHTNESS_SWITCH,
+ PROP_BRIGHTNESS_SWITCH_SAVE,
N_PROPERTIES
};
@@ -318,6 +320,15 @@ xfpm_backlight_class_init (XfpmBacklightClass *klass)
-1,
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_BRIGHTNESS_SWITCH_SAVE,
+ g_param_spec_int (BRIGHTNESS_SWITCH_SAVE,
+ NULL, NULL,
+ -1,
+ 1,
+ -1,
+ G_PARAM_READWRITE));
+
g_type_class_add_private (klass, sizeof (XfpmBacklightPrivate));
}
@@ -389,6 +400,9 @@ xfpm_backlight_get_property (GObject *object,
case PROP_BRIGHTNESS_SWITCH:
g_value_set_int (value, backlight->priv->brightness_switch);
break;
+ case PROP_BRIGHTNESS_SWITCH_SAVE:
+ g_value_set_int (value, backlight->priv->brightness_switch_save);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -418,6 +432,9 @@ xfpm_backlight_set_property (GObject *object,
backlight->priv->brightness_switch);
break;
+ case PROP_BRIGHTNESS_SWITCH_SAVE:
+ backlight->priv->brightness_switch_save = g_value_get_int (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
diff --git a/src/xfpm-config.h b/src/xfpm-config.h
index 488f1de..1281822 100644
--- a/src/xfpm-config.h
+++ b/src/xfpm-config.h
@@ -68,6 +68,7 @@ G_BEGIN_DECLS
#define HANDLE_BRIGHTNESS_KEYS "handle-brightness-keys"
#define BRIGHTNESS_SWITCH "brightness-switch"
+#define BRIGHTNESS_SWITCH_SAVE "brightness-switch-restore-on-exit"
#define SHOW_TRAY_ICON_CFG "show-tray-icon"
#define CRITICAL_BATT_ACTION_CFG "critical-power-action"
diff --git a/src/xfpm-xfconf.c b/src/xfpm-xfconf.c
index decd308..08d6d9f 100644
--- a/src/xfpm-xfconf.c
+++ b/src/xfpm-xfconf.c
@@ -194,7 +194,8 @@ xfpm_xfconf_property_changed_cb (XfconfChannel *channel, gchar *property,
return;
/* We handle brightness switch in xfpm-backlight directly */
- if ( g_strcmp0 (property, PROPERTIES_PREFIX BRIGHTNESS_SWITCH) == 0 )
+ if ( g_strcmp0 (property, PROPERTIES_PREFIX BRIGHTNESS_SWITCH) == 0 ||
+ g_strcmp0 (property, PROPERTIES_PREFIX BRIGHTNESS_SWITCH_SAVE) == 0 )
return;
XFPM_DEBUG ("Property modified: %s\n", property);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list