[ohm] Heads up (was ohm: Branch 'master' - 15 commits)

Rob Taylor rob.taylor at codethink.co.uk
Wed Aug 22 07:55:19 PDT 2007


Heads up for distributors using git HEAD - this introduces a required
configure flag --with-xauth-dir, which is used to set the directory in
which to find the .Xauthority file for connecting to the xserver. This
only applies to single-user devices with a known user home directory -
-but currently this is all OHM supports, pending ConsoleKit work.

Previously the patch /home/olpc was hardcoded for this value.

Thanks,
Rob

P.S. Apologies for pushing so many patches at once!

Rob Taylor wrote:
>  Makefile.am                                   |    2 
>  configure.in                                  |   20 +++++
>  ohmd/ohm-module.c                             |    4 -
>  ohmd/ohm-plugin-internal.h                    |    1 
>  ohmd/ohm-plugin.c                             |   21 ++++-
>  ohmd/run-ohm.sh                               |    1 
>  plugins/glue/backlight/ohm-plugin-backlight.c |   16 ++--
>  plugins/glue/dpms/ohm-plugin-dpms.c           |    6 +
>  plugins/glue/idle/Makefile.am                 |    4 -
>  plugins/glue/idle/README                      |   17 ++++
>  plugins/glue/idle/idle.ini                    |    5 -
>  plugins/glue/idle/ohm-plugin-idle.c           |   67 +++++++++--------
>  plugins/glue/xorg/ohm-plugin-xorg.c           |   21 +++--
>  plugins/policy/Makefile.am                    |    3 
>  plugins/policy/display/ohm-plugin-display.c   |   14 +--
>  plugins/policy/suspend/ohm-plugin-suspend.c   |    9 +-
>  plugins/policy/timeouts/Makefile.am           |   10 ++
>  plugins/policy/timeouts/timeouts.c            |  100 ++++++++++++++++++++++++++
>  plugins/policy/timeouts/timeouts.ini          |    4 +
>  19 files changed, 252 insertions(+), 73 deletions(-)
> 
> New commits:
> diff-tree 5adfae30f655b11383c440938e9c08fc6ea8314a (from f25e07b522c757722c8b8ada2c0201b122355731)
> Author: Rob Taylor <rob.taylor at codethink.co.uk>
> Date:   Wed Aug 22 15:06:19 2007 +0100
> 
>     add configure flags for distcheck
>     
>     Pass --enable-gtk-doc and --with-xauth-dir=/home/user for distcheck to check
>     documentation building and to pass configure.
> 
> diff --git a/Makefile.am b/Makefile.am
> index c861665..218a290 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -43,3 +43,5 @@ MAINTAINERCLEANFILES =	\
>  	autom4te.cache/*		\
>  	po/$(GETTEXT_PACKAGE).pot	\
>  	po/*.bak
> +
> +DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc --with-xauth-dir=/home/user
> diff-tree f25e07b522c757722c8b8ada2c0201b122355731 (from 7ba694c385e62e6d668202952969c007ab364792)
> Author: Rob Taylor <rob.taylor at codethink.co.uk>
> Date:   Wed Aug 22 14:49:15 2007 +0100
> 
>     add some debug when suspending
>     
>     In the suspend policy plugin, add some debug output before suspending for ease
>     of debugging...
> 
> diff --git a/plugins/policy/suspend/ohm-plugin-suspend.c b/plugins/policy/suspend/ohm-plugin-suspend.c
> index 794dcef..5fe9dd2 100644
> --- a/plugins/policy/suspend/ohm-plugin-suspend.c
> +++ b/plugins/policy/suspend/ohm-plugin-suspend.c
> @@ -151,6 +151,7 @@ plugin_notify (OhmPlugin *plugin, gint i
>  	} else if (id == CONF_TIMEOUTS_POWERDOWN_CHANGED) {
>  		/* only match on idle, not reset */
>  		if (value == 1) {
> +			g_debug ("powerdown is 1, suspending");
>  			system_is_idle (plugin);
>  		}
>  	}
> diff-tree 7ba694c385e62e6d668202952969c007ab364792 (from dae3b4dd679d9209afa9447298e8a056ebefc411)
> Author: Rob Taylor <rob.taylor at codethink.co.uk>
> Date:   Wed Aug 22 14:48:11 2007 +0100
> 
>     fixes for the new idle plugin interface
>     
>     Cope with start case where idle.timeout is 0. Cope with delayed X connection.
>     Timeouts are measured from last activity, not last alarm.
> 
> diff --git a/plugins/glue/idle/ohm-plugin-idle.c b/plugins/glue/idle/ohm-plugin-idle.c
> index 74aed96..5c6bff4 100644
> --- a/plugins/glue/idle/ohm-plugin-idle.c
> +++ b/plugins/glue/idle/ohm-plugin-idle.c
> @@ -67,13 +67,15 @@ plugin_connect_idletime (OhmPlugin *plug
>  	g_signal_connect (idletime, "alarm-expired",
>  			  G_CALLBACK (ohm_alarm_expired_cb), plugin);
>  
> -	ohm_plugin_conf_get_key (plugin, "idle.timeout", &timeout);
> -
>  	ohm_plugin_conf_set_key (plugin, "idle.state", 0);
>  
> -	ret = idletime_alarm_set (idletime, 1, timeout);
> -	if (ret == FALSE) {
> -		g_error ("cannot set alarm");
> +	ohm_plugin_conf_get_key (plugin, "idle.timeout", &timeout);
> +
> +	if (timeout != 0) {
> +		ret = idletime_alarm_set (idletime, 1, timeout);
> +		if (ret == FALSE) {
> +			g_error ("cannot set alarm");
> +		}
>  	}
>  }
>  
> @@ -114,12 +116,16 @@ plugin_notify (OhmPlugin *plugin, gint i
>  		if (value == 1) {
>  			plugin_connect_idletime (plugin);
>  		}
> -	} else if (id == CONF_IDLE_TIMEOUT_CHANGED ) {
> -		idletime_alarm_set (idletime, 1, value);
> -	} else if (id == CONF_IDLE_STATE_CHANGED ) {
> -		if (value == 0) {
> -			ohm_plugin_conf_get_key (plugin, "idle.timeout", &timeout);
> -			idletime_alarm_set (idletime, 1, timeout);
> +	}
> +	if (idletime) {
> +		if (id == CONF_IDLE_TIMEOUT_CHANGED ) {
> +			g_debug("setting new timeout %d", value);
> +			idletime_alarm_set (idletime, 1, value);
> +		} else if (id == CONF_IDLE_STATE_CHANGED ) {
> +			if (value == 0) {
> +				ohm_plugin_conf_get_key (plugin, "idle.timeout", &timeout);
> +				idletime_alarm_set (idletime, 1, timeout);
> +			}
>  		}
>  	}
>  }
> @@ -142,7 +148,7 @@ OHM_PLUGIN_DESCRIPTION (
>  
>  OHM_PLUGIN_REQUIRES ("xorg");
>  
> -OHM_PLUGIN_PROVIDES ("idle.state");
> +OHM_PLUGIN_PROVIDES ("idle.state", "idle.timeout");
>  
>  OHM_PLUGIN_INTERESTED (
>  	{"xorg.has_xauthority", CONF_XORG_HASXAUTH_CHANGED},
> diff --git a/plugins/policy/timeouts/timeouts.c b/plugins/policy/timeouts/timeouts.c
> index 133dd36..718af5b 100644
> --- a/plugins/policy/timeouts/timeouts.c
> +++ b/plugins/policy/timeouts/timeouts.c
> @@ -41,29 +41,30 @@ init (OhmPlugin *plugin)
>  static void
>  notify (OhmPlugin *plugin, gint id, gint value)
>  {
> -	gint new_timeout, old_timeout;
> +	gint new_timeout;
>  
>  	if (id != CONF_IDLE_STATE_CHANGED)
>  		return;
>  
>  	switch (value) {
>  	case 0:
> -		ohm_plugin_conf_get_key (plugin, "timeouts.timer_momentary", &new_timeout);
> +		ohm_plugin_conf_get_key (plugin, "timeouts.timer_momentary",
> +					 &new_timeout);
>  		ohm_plugin_conf_set_key (plugin, "idle.timeout", new_timeout);
>  		ohm_plugin_conf_set_key (plugin, "timeouts.momentary", 0);
>  		ohm_plugin_conf_set_key (plugin, "timeouts.powersave", 0);
>  		ohm_plugin_conf_set_key (plugin, "timeouts.powerdown", 0);
>  		break;
>  	case 1:
> -		ohm_plugin_conf_get_key (plugin, "timeouts.timer_powersave", &new_timeout);
> -		ohm_plugin_conf_get_key (plugin, "timeouts.timer_momentary", &old_timeout);
> -		ohm_plugin_conf_set_key (plugin, "idle.timeout", new_timeout-old_timeout);
> +		ohm_plugin_conf_get_key (plugin, "timeouts.timer_powersave",
> +					 &new_timeout);
> +		ohm_plugin_conf_set_key (plugin, "idle.timeout", new_timeout);
>  		ohm_plugin_conf_set_key (plugin, "timeouts.momentary", 1);
>  		break;
>  	case 2:
> -		ohm_plugin_conf_get_key (plugin, "timeouts.timer_powerdown", &new_timeout);
> -		ohm_plugin_conf_get_key (plugin, "timeouts.timer_powersave", &old_timeout);
> -		ohm_plugin_conf_set_key (plugin, "idle.timeout", new_timeout-old_timeout);
> +		ohm_plugin_conf_get_key (plugin, "timeouts.timer_powerdown",
> +					 &new_timeout);
> +		ohm_plugin_conf_set_key (plugin, "idle.timeout", new_timeout);
>  		ohm_plugin_conf_set_key (plugin, "timeouts.powersave", 1);
>  		break;
>  	case 3:
> diff-tree dae3b4dd679d9209afa9447298e8a056ebefc411 (from 06e0d187cf16ad9f093b2d5136dca50e2fe8f3c3)
> Author: Rob Taylor <rob.taylor at codethink.co.uk>
> Date:   Wed Aug 22 14:43:28 2007 +0100
> 
>     add configure flag for .Xauthorty directory on single-user-devices
>     
>     Adds the manditory configure flag --with-xauth-dir= for the directory in which
>     to find a .Xauthority for the xserver instance on single-user-devices, e.g.
>     OLPC and N800.
>     
>     For now configure assumes builds are only for single-user devices.
>     Multiple-user cases will require ConsoleKit integration, and some work on
>     ConsoleKit.
> 
> diff --git a/configure.in b/configure.in
> index b09441d..9eda015 100644
> --- a/configure.in
> +++ b/configure.in
> @@ -112,6 +112,25 @@ AC_SUBST(OHM_PLUGIN_DIR, "\$(libdir)/ohm
>  AC_SUBST(OHM_PLUGIN_CFLAGS, "-I\$(top_srcdir)/ohmd $GLIB_CFLAGS $DBUS_CFLAGS $GMODULE_CFLAGS")
>  AC_SUBST(OHM_PLUGIN_LIBS, "$GLIB_LIBS $DBUS_LIBS $GMODULE_LIBS")
>  
> +dnl Assume single-user-device for now
> +single_user_device="yes"
> +
> +if test "$single_user_device" = yes; then
> +	AC_DEFINE(OHM_SINGLE_USER_DEVICE, 1, [Whether OHM is built for a single-user device with a known .Xauthority location])
> +
> +	AC_ARG_WITH(xauth-dir,
> +		[AC_HELP_STRING([--with-xauth-dir=<dir>],
> +			[directory where we can find .Xauthority (for single-user device)]
> +			)]
> +		)
> +
> +	if test -z "$with_xauth_dir"; then
> +		AC_MSG_ERROR([Must use --with-xauth-dir for a single-user device]) 
> +	else
> +		AC_DEFINE(OHM_DEVICE_XAUTH_DIR, "$xauth_dir", [Where to find .Xauthority])
> +	fi
> +fi
> +
>  dnl ---------------------------------------------------------------------------
>  dnl - Where should we put documentation ?
>  dnl ---------------------------------------------------------------------------
> diff --git a/plugins/glue/xorg/ohm-plugin-xorg.c b/plugins/glue/xorg/ohm-plugin-xorg.c
> index 3f0b226..f91c8af 100644
> --- a/plugins/glue/xorg/ohm-plugin-xorg.c
> +++ b/plugins/glue/xorg/ohm-plugin-xorg.c
> @@ -35,20 +35,27 @@ plugin_poll_startup (gpointer data)
>  	gboolean ret;
>  	const gchar *xauth;
>  
> -	/* we should search all of home */
> -	xauth = "/home/olpc/.Xauthority";
> +#ifdef OHM_SINGLE_USER_DEVICE
> +	xauth = OHM_DEVICE_XAUTH_DIR "/.Xauthority";
> +	g_debug ("xorg: testing %s", xauth);
>  	ret = g_file_test (xauth, G_FILE_TEST_EXISTS);
>  
> -	/* be nice to hughsie... */
> +	/* be nice to developers... */
>  	if (ret == FALSE) {
> -		xauth = "/home/hughsie/.Xauthority";
> -		ret = g_file_test (xauth, G_FILE_TEST_EXISTS);
> +		const char *home = getenv("HOME");
> +		if (home != NULL) {
> +			xauth = g_strdup_printf ("%s/.Xauthority", home);
> +			g_debug ("xorg: testing %s", xauth);
> +			ret = g_file_test (xauth, G_FILE_TEST_EXISTS);
> +		}
>  	}
>  	if (ret == FALSE) {
> -		/* not yet */
> +		g_debug ("xorg: no .Xauthority found");
>  		return TRUE;
>  	}
> -
> +#else
> +#error ConsoleKit support not yet implemented
> +#endif
>  	/* woot! X is alive */
>  	g_debug ("Got X!");
>  	ohm_plugin_conf_set_key (plugin, "xorg.has_xauthority", 1);
> diff-tree 06e0d187cf16ad9f093b2d5136dca50e2fe8f3c3 (from fb7a82c5a7425d14e248a44d5a7fc15e987a8943)
> Author: Rob Taylor <rob.taylor at codethink.co.uk>
> Date:   Wed Aug 22 14:38:33 2007 +0100
> 
>     fix dpms plugin to not crash at end if failed to connect to xserver
>     
>     Fix dpms plugin to not crash at end if failed to connect to xserver.
> 
> diff --git a/plugins/glue/dpms/ohm-plugin-dpms.c b/plugins/glue/dpms/ohm-plugin-dpms.c
> index 603b5d7..9826918 100644
> --- a/plugins/glue/dpms/ohm-plugin-dpms.c
> +++ b/plugins/glue/dpms/ohm-plugin-dpms.c
> @@ -175,8 +175,10 @@ plugin_initalize (OhmPlugin *plugin)
>  static void
>  plugin_destroy (OhmPlugin *plugin)
>  {
> -	XCloseDisplay (dpy);
> -	dpy = NULL;
> +	if (dpy) {
> +		XCloseDisplay (dpy);
> +		dpy = NULL;
> +	}
>  }
>  
>  /**
> diff-tree fb7a82c5a7425d14e248a44d5a7fc15e987a8943 (from 26315eca26197a541184190f41d6683f8939d003)
> Author: Rob Taylor <rob.taylor at codethink.co.uk>
> Date:   Wed Aug 22 14:37:23 2007 +0100
> 
>     fix backlight plugin not to crash when no laptop_panels found.
>     
>     Fix backlight plugin not to crash when no laptop_panels found.
> 
> diff --git a/plugins/glue/backlight/ohm-plugin-backlight.c b/plugins/glue/backlight/ohm-plugin-backlight.c
> index 8950972..19c0272 100644
> --- a/plugins/glue/backlight/ohm-plugin-backlight.c
> +++ b/plugins/glue/backlight/ohm-plugin-backlight.c
> @@ -148,17 +148,19 @@ plugin_initalize (OhmPlugin *plugin)
>  
>  	/* get the only device with capability and watch it */
>  	num = ohm_plugin_hal_add_device_capability (plugin, "laptop_panel");
> -	if (num != 1) {
> +	if (num > 1) {
>  		g_warning ("not tested with not one laptop_panel");
>  	}
>  
> -	/* get levels that the adapter supports -- this does not change ever */
> -	ohm_plugin_hal_get_int (plugin, 0, "laptop_panel.num_levels", &data.levels);
> -	if (data.levels == 0) {
> -		g_error ("levels zero!");
> -		return;
> +	if (num != 0) {
> +		/* get levels that the adapter supports -- this does not change ever */
> +		ohm_plugin_hal_get_int (plugin, 0, "laptop_panel.num_levels", &data.levels);
> +		if (data.levels == 0) {
> +			g_error ("levels zero!");
> +			return;
> +		}
> +		ohm_plugin_conf_set_key (plugin, "backlight.num_levels", data.levels);
>  	}
> -	ohm_plugin_conf_set_key (plugin, "backlight.num_levels", data.levels);
>  }
>  
>  /**
> diff-tree 26315eca26197a541184190f41d6683f8939d003 (from af911c97b3e14271d50c68632760324efcb4fdf9)
> Author: Rob Taylor <rob.taylor at codethink.co.uk>
> Date:   Mon Aug 20 10:12:31 2007 +0100
> 
>     convert existing policy plugins to use the timeouts policy module
>     
>     Convert suspend and display policy plugins to use the new timouts policy
>     instead of the old idle plugin interface.
> 
> diff --git a/plugins/policy/display/ohm-plugin-display.c b/plugins/policy/display/ohm-plugin-display.c
> index a81f1d2..cfb032c 100644
> --- a/plugins/policy/display/ohm-plugin-display.c
> +++ b/plugins/policy/display/ohm-plugin-display.c
> @@ -30,8 +30,8 @@ enum {
>  	CONF_BRIGHTNESS_AC_CHANGED,
>  	CONF_BRIGHTNESS_BATTERY_CHANGED,
>  	CONF_BRIGHTNESS_IDLE_CHANGED,
> -	CONF_IDLE_POWERSAVE_CHANGED,
> -	CONF_IDLE_MOMENTARY_CHANGED,
> +	CONF_TIMEOUTS_POWERSAVE_CHANGED,
> +	CONF_TIMEOUTS_MOMENTARY_CHANGED,
>  	CONF_LAST
>  };
>  
> @@ -147,7 +147,7 @@ plugin_notify (OhmPlugin *plugin, gint i
>  	case CONF_BRIGHTNESS_IDLE_CHANGED:
>  		reset_brightness (plugin);
>  		break;
> -	case CONF_IDLE_POWERSAVE_CHANGED:
> +	case CONF_TIMEOUTS_POWERSAVE_CHANGED:
>  		backlight_powersave (plugin, (value == 1));
>  		break;
>  	case CONF_LID_STATE_CHANGED:
> @@ -164,7 +164,7 @@ plugin_notify (OhmPlugin *plugin, gint i
>  	case CONF_BACKLIGHT_STATE_CHANGED:
>  		reset_brightness (plugin);
>  		break;
> -	case CONF_IDLE_MOMENTARY_CHANGED:
> +	case CONF_TIMEOUTS_MOMENTARY_CHANGED:
>  		brightness_momentary (plugin, (value == 1));
>  		break;
>  	}
> @@ -181,7 +181,7 @@ OHM_PLUGIN_DESCRIPTION (
>  );
>  
>  OHM_PLUGIN_SUGGESTS (
> -	"idle",
> +	"timeouts",
>  	"acadapter",
>  	"buttons",
>  	"xrandr",
> @@ -193,8 +193,8 @@ OHM_PLUGIN_INTERESTED (
>  	{"backlight.state", CONF_BACKLIGHT_STATE_CHANGED},
>  	{"button.lid", CONF_LID_STATE_CHANGED},
>  	{"button.tablet", CONF_TABLET_STATE_CHANGED},
> -	{"idle.powersave", CONF_IDLE_POWERSAVE_CHANGED},
> -	{"idle.momentary", CONF_IDLE_MOMENTARY_CHANGED},
> +	{"timeouts.powersave", CONF_TIMEOUTS_POWERSAVE_CHANGED},
> +	{"timeouts.momentary", CONF_TIMEOUTS_MOMENTARY_CHANGED},
>  	{"display.value_ac", CONF_BRIGHTNESS_AC_CHANGED},
>  	{"display.value_battery", CONF_BRIGHTNESS_BATTERY_CHANGED},
>  	{"display.value_idle", CONF_BRIGHTNESS_IDLE_CHANGED}
> diff --git a/plugins/policy/suspend/ohm-plugin-suspend.c b/plugins/policy/suspend/ohm-plugin-suspend.c
> index 2c3d5c5..794dcef 100644
> --- a/plugins/policy/suspend/ohm-plugin-suspend.c
> +++ b/plugins/policy/suspend/ohm-plugin-suspend.c
> @@ -30,7 +30,7 @@
>  enum {
>  	CONF_BUTTON_POWER_CHANGED,
>  	CONF_BUTTON_LID_CHANGED,
> -	CONF_IDLE_POWERDOWN_CHANGED,
> +	CONF_TIMEOUTS_POWERDOWN_CHANGED,
>  	CONF_INHIBIT_CHANGED,
>  	CONF_LAST
>  };
> @@ -148,7 +148,7 @@ plugin_notify (OhmPlugin *plugin, gint i
>  		if (value == 1) {
>  			power_button_pressed (plugin);
>  		}
> -	} else if (id == CONF_IDLE_POWERDOWN_CHANGED) {
> +	} else if (id == CONF_TIMEOUTS_POWERDOWN_CHANGED) {
>  		/* only match on idle, not reset */
>  		if (value == 1) {
>  			system_is_idle (plugin);
> @@ -167,13 +167,13 @@ OHM_PLUGIN_DESCRIPTION (
>  );
>  
>  OHM_PLUGIN_SUGGESTS (
> -	"idle",
> +	"timeouts",
>  	"buttons"
>  );
>  
>  OHM_PLUGIN_INTERESTED (
>  	{"button.power", CONF_BUTTON_POWER_CHANGED},
>  	{"button.lid", CONF_BUTTON_LID_CHANGED},
> -	{"idle.powerdown", CONF_IDLE_POWERDOWN_CHANGED},
> +	{"timeouts.powerdown", CONF_TIMEOUTS_POWERDOWN_CHANGED},
>  	{"suspend.fixme_inhibit", CONF_INHIBIT_CHANGED}
>  );
> diff-tree af911c97b3e14271d50c68632760324efcb4fdf9 (from 6da58414a9eee009d293400155869319597bc171)
> Author: Rob Taylor <rob.taylor at codethink.co.uk>
> Date:   Sat Aug 18 17:31:28 2007 +0100
> 
>     allow a plugin to have no defaults ini file.
>     
>     Allow a plugin to have no defaults ini file, just output a debug message in this
>     case rather than g_error.
> 
> diff --git a/ohmd/ohm-module.c b/ohmd/ohm-module.c
> index 99dc34a..f306aff 100644
> --- a/ohmd/ohm-module.c
> +++ b/ohmd/ohm-module.c
> @@ -448,7 +448,7 @@ ohm_module_init (OhmModule *module)
>  		error = NULL;
>  		ret = ohm_conf_load_defaults (module->priv->conf, name, &error);
>  		if (ret == FALSE) {
> -			g_error ("could not load defaults : %s", error->message);
> +			ohm_debug ("not defaults for %s: %s", name, error->message);
>  			g_error_free (error);
>  		}
>  	}
> diff-tree 6da58414a9eee009d293400155869319597bc171 (from 516af01cdf9a852ae94075acb6b4d4e6a7d4ca08)
> Author: Rob Taylor <rob.taylor at codethink.co.uk>
> Date:   Sat Aug 18 17:21:53 2007 +0100
> 
>     remove idle.ini, no longer needed.
>     
>     As idle is now just a mechnism, remove default key settings for timeout.
> 
> diff --git a/plugins/glue/idle/Makefile.am b/plugins/glue/idle/Makefile.am
> index c5d332d..d19439c 100644
> --- a/plugins/glue/idle/Makefile.am
> +++ b/plugins/glue/idle/Makefile.am
> @@ -1,10 +1,6 @@
>  LOCAL_LIBIDLETIME_LIBS = $(top_builddir)/libidletime/libidletime.la
>  LOCAL_LIBIDLETIME_CFLAGS = -I$(top_srcdir)/libidletime
>  
> -EXTRA_DIST = $(Data_DATA)
> -Datadir = @OHM_PLUGIN_CONF_DIR@
> -Data_DATA = idle.ini
> -
>  plugindir = @OHM_PLUGIN_DIR@
>  plugin_LTLIBRARIES = libohm_idle.la
>  libohm_idle_la_SOURCES = ohm-plugin-idle.c
> diff --git a/plugins/glue/idle/idle.ini b/plugins/glue/idle/idle.ini
> deleted file mode 100644
> index 72605d6..0000000
> --- a/plugins/glue/idle/idle.ini
> +++ /dev/null
> @@ -1,4 +0,0 @@
> -# idle preference values
> -idle.timeout 5000 public
> -idle.state 0 public
> -
> diff-tree 516af01cdf9a852ae94075acb6b4d4e6a7d4ca08 (from 74fa413f385a77194bddfdef23793838fee2f413)
> Author: Rob Taylor <rob.taylor at codethink.co.uk>
> Date:   Sat Aug 18 17:21:06 2007 +0100
> 
>     fix up changes to idle plugin
>     
>     Fix build errors in idle plugin.
>     Listen for idle.state being set to 0 and if so, reset to the current timeout.
> 
> diff --git a/plugins/glue/idle/ohm-plugin-idle.c b/plugins/glue/idle/ohm-plugin-idle.c
> index 1571671..74aed96 100644
> --- a/plugins/glue/idle/ohm-plugin-idle.c
> +++ b/plugins/glue/idle/ohm-plugin-idle.c
> @@ -30,6 +30,7 @@ static LibIdletime *idletime = NULL;
>  enum {
>  	CONF_XORG_HASXAUTH_CHANGED,
>  	CONF_IDLE_TIMEOUT_CHANGED,
> +	CONF_IDLE_STATE_CHANGED,
>  	CONF_LAST
>  };
>  
> @@ -43,7 +44,7 @@ ohm_alarm_expired_cb (LibIdletime *idlet
>  		/* activity, reset state to 0 */
>  		ohm_plugin_conf_set_key (plugin, "idle.state", 0);
>  	} else {
> -		ohm_plugin_conf_get_key (plugin, "idle.state", &tate);
> +		ohm_plugin_conf_get_key (plugin, "idle.state", &state);
>  		ohm_plugin_conf_set_key (plugin, "idle.state", state+1);
>  	}
>  	g_print ("[evt %i]\n", alarm);
> @@ -70,7 +71,7 @@ plugin_connect_idletime (OhmPlugin *plug
>  
>  	ohm_plugin_conf_set_key (plugin, "idle.state", 0);
>  
> -	ret = idletime_alarm_set (idletime, 1, momentary);
> +	ret = idletime_alarm_set (idletime, 1, timeout);
>  	if (ret == FALSE) {
>  		g_error ("cannot set alarm");
>  	}
> @@ -108,12 +109,18 @@ plugin_initalize (OhmPlugin *plugin)
>  static void
>  plugin_notify (OhmPlugin *plugin, gint id, gint value)
>  {
> +	gint timeout;
>  	if (id == CONF_XORG_HASXAUTH_CHANGED) {
>  		if (value == 1) {
>  			plugin_connect_idletime (plugin);
>  		}
>  	} else if (id == CONF_IDLE_TIMEOUT_CHANGED ) {
>  		idletime_alarm_set (idletime, 1, value);
> +	} else if (id == CONF_IDLE_STATE_CHANGED ) {
> +		if (value == 0) {
> +			ohm_plugin_conf_get_key (plugin, "idle.timeout", &timeout);
> +			idletime_alarm_set (idletime, 1, timeout);
> +		}
>  	}
>  }
>  static void
> @@ -135,7 +142,9 @@ OHM_PLUGIN_DESCRIPTION (
>  
>  OHM_PLUGIN_REQUIRES ("xorg");
>  
> -OHM_PLUGIN_PROVIDES ("idle.state", "idle.timeout");
> +OHM_PLUGIN_PROVIDES ("idle.state");
>  
> -OHM_PLUGIN_INTERESTED ({"xorg.has_xauthority", CONF_XORG_HASXAUTH_CHANGED});
> -OHM_PLUGIN_INTERESTED ({"idle.timeout", CONF_IDLE_TIMEOUT_CHANGED});
> +OHM_PLUGIN_INTERESTED (
> +	{"xorg.has_xauthority", CONF_XORG_HASXAUTH_CHANGED},
> +	{"idle.timeout", CONF_IDLE_TIMEOUT_CHANGED},
> +	{"idle.state", CONF_IDLE_STATE_CHANGED});
> diff-tree 74fa413f385a77194bddfdef23793838fee2f413 (from e0150c441c87eb2e203c1d33a6003f62ff49337e)
> Author: Rob Taylor <rob.taylor at codethink.co.uk>
> Date:   Sat Aug 18 17:18:45 2007 +0100
> 
>     clean out the temp plugin install directory in run-ohm.sh
>     
>     If run-ohm.sh is not invoked with --skip-plugin-install, clean out the temp dir
>     before installing the plugins.
> 
> diff --git a/ohmd/run-ohm.sh b/ohmd/run-ohm.sh
> index 72f1352..dd94017 100755
> --- a/ohmd/run-ohm.sh
> +++ b/ohmd/run-ohm.sh
> @@ -24,6 +24,7 @@ fi
>  if [ "$1" = "--skip-plugin-install" ] ; then
>  	shift
>  else
> +	rm -rf $OHM_TMPDIR
>  	make -C ../etc install DESTDIR=$OHM_TMPDIR prefix=/
>  	make -C ../plugins install DESTDIR=$OHM_TMPDIR prefix=/
>  fi
> diff-tree e0150c441c87eb2e203c1d33a6003f62ff49337e (from 1b3a9e232dfde6d115d20275376c4e817ad3109d)
> Author: Rob Taylor <rob.taylor at codethink.co.uk>
> Date:   Sat Aug 18 17:17:12 2007 +0100
> 
>     support for a plugin to listen on its own keys
>     
>     Allow a plugin to listen to changes on a key it sets. A plugin will not be notified when it sets the key itself only when another plugin sets the key.
> 
> diff --git a/ohmd/ohm-module.c b/ohmd/ohm-module.c
> index 6ee2154..99dc34a 100644
> --- a/ohmd/ohm-module.c
> +++ b/ohmd/ohm-module.c
> @@ -107,7 +107,7 @@ key_changed_cb (OhmConf     *conf,
>  		notif = (OhmModuleNotify *) l->data;
>  		name = ohm_plugin_get_name (notif->plugin);
>  		ohm_debug ("notify %s with id:%i", name, notif->id);
> -		ohm_plugin_notify (notif->plugin, notif->id, value);
> +		ohm_plugin_notify (notif->plugin, key, notif->id, value);
>  	}
>  }
>  
> diff --git a/ohmd/ohm-plugin-internal.h b/ohmd/ohm-plugin-internal.h
> index 92c9bcb..00eea75 100644
> --- a/ohmd/ohm-plugin-internal.h
> +++ b/ohmd/ohm-plugin-internal.h
> @@ -63,6 +63,7 @@ const gchar	*ohm_plugin_get_name			(OhmP
>  const gchar	*ohm_plugin_get_version			(OhmPlugin	*plugin);
>  const gchar	*ohm_plugin_get_author			(OhmPlugin	*plugin);
>  gboolean	 ohm_plugin_notify			(OhmPlugin      *plugin,
> +							 const char	*key,
>  							 gint		 id,
>  							 gint		 value);
>  
> diff --git a/ohmd/ohm-plugin.c b/ohmd/ohm-plugin.c
> index 4012e48..1480ebd 100644
> --- a/ohmd/ohm-plugin.c
> +++ b/ohmd/ohm-plugin.c
> @@ -59,6 +59,7 @@ struct _OhmPluginPrivate
>  	GPtrArray		*hal_udis;
>  	OhmPluginHalPropMod	 hal_property_changed_cb;
>  	OhmPluginHalCondition	 hal_condition_cb;
> +	const char		*key_being_set;
>  };
>  
>  G_DEFINE_TYPE (OhmPlugin, ohm_plugin, G_TYPE_OBJECT)
> @@ -154,7 +155,13 @@ ohm_plugin_conf_set_key (OhmPlugin   *pl
>  	gboolean ret;
>  	error = NULL;
>  
> +	/* key_being_set is used to stop a plugin changing a key notifying
> +	 * itself if it's interest in that key
> +	 */
> +	plugin->priv->key_being_set = key;
>  	ret = ohm_conf_set_key_internal (plugin->priv->conf, key, value, TRUE, &error);
> +	plugin->priv->key_being_set = NULL;
> +
>  	if (ret == FALSE) {
>  		g_error ("Cannot set key: %s", error->message);
>  		g_error_free (error);
> @@ -164,9 +171,17 @@ ohm_plugin_conf_set_key (OhmPlugin   *pl
>  
>  gboolean
>  ohm_plugin_notify (OhmPlugin   *plugin,
> -			int     id,
> -			int     value)
> -{
> +		   const char *key,
> +		   int     id,
> +		   int     value)
> +{
> +	/* check that it wasn't this plugin that changed the key in 
> +	 * the first place
> +	 */
> +	if (plugin->priv->key_being_set &&
> +	    strcmp(plugin->priv->key_being_set, key) == 0)
> +		return TRUE;
> +
>  	plugin->desc->notify (plugin, id, value);
>  	return TRUE;
>  }
> diff-tree 1b3a9e232dfde6d115d20275376c4e817ad3109d (from c6b1dc765bd1f769bf8e365795f9a798e920e82d)
> Author: Rob Taylor <rob.taylor at codethink.co.uk>
> Date:   Sat Aug 18 16:24:38 2007 +0100
> 
>     add 'timeouts' policy module.
>     
>     This implements a simple 3 state timeout policy on top of the idle mechanism plugin.
> 
> diff --git a/configure.in b/configure.in
> index 24ad0df..b09441d 100644
> --- a/configure.in
> +++ b/configure.in
> @@ -321,6 +321,7 @@ plugins/glue/xorg/Makefile
>  plugins/policy/Makefile
>  plugins/policy/display/Makefile
>  plugins/policy/suspend/Makefile
> +plugins/policy/timeouts/Makefile
>  ohmd/Makefile
>  po/Makefile.in
>  docs/Makefile
> diff --git a/plugins/policy/Makefile.am b/plugins/policy/Makefile.am
> index b3aee80..7d271f9 100644
> --- a/plugins/policy/Makefile.am
> +++ b/plugins/policy/Makefile.am
> @@ -1,6 +1,7 @@
>  SUBDIRS = 				\
>  	display				\
> -	suspend
> +	suspend				\
> +	timeouts
>  
>  clean-local:
>  	rm -f *~
> diff --git a/plugins/policy/timeouts/Makefile.am b/plugins/policy/timeouts/Makefile.am
> new file mode 100644
> index 0000000..e7abfa0
> --- /dev/null
> +++ b/plugins/policy/timeouts/Makefile.am
> @@ -0,0 +1,10 @@
> +EXTRA_DIST = $(Data_DATA)
> +Datadir = @OHM_PLUGIN_CONF_DIR@
> +Data_DATA = timeouts.ini
> +
> +plugindir = @OHM_PLUGIN_DIR@
> +plugin_LTLIBRARIES = libohm_timeouts.la
> +libohm_timeouts_la_SOURCES = timeouts.c
> +libohm_timeouts_la_LIBADD = @OHM_PLUGIN_LIBS@
> +libohm_timeouts_la_LDFLAGS = -module -avoid-version
> +libohm_timeouts_la_CFLAGS = @OHM_PLUGIN_CFLAGS@
> diff --git a/plugins/policy/timeouts/timeouts.c b/plugins/policy/timeouts/timeouts.c
> new file mode 100644
> index 0000000..133dd36
> --- /dev/null
> +++ b/plugins/policy/timeouts/timeouts.c
> @@ -0,0 +1,99 @@
> +/*
> + * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
> + *
> + * Licensed under the GNU Lesser General Public License Version 2
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + * 
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + * 
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
> + */
> +
> +#include <gmodule.h>
> +#include <glib.h>
> +#include <ohm-plugin.h>
> +
> +enum {
> +	CONF_IDLE_STATE_CHANGED,
> +	CONF_LAST
> +};
> +
> +
> +static void
> +init (OhmPlugin *plugin)
> +{
> +	gint first_timeout;
> +
> +	ohm_plugin_conf_get_key (plugin, "timeouts.timer_momentary", &first_timeout);
> +	ohm_plugin_conf_set_key (plugin, "idle.timeout", first_timeout);
> +	ohm_plugin_conf_set_key (plugin, "idle.state", 0);
> +}
> +
> +static void
> +notify (OhmPlugin *plugin, gint id, gint value)
> +{
> +	gint new_timeout, old_timeout;
> +
> +	if (id != CONF_IDLE_STATE_CHANGED)
> +		return;
> +
> +	switch (value) {
> +	case 0:
> +		ohm_plugin_conf_get_key (plugin, "timeouts.timer_momentary", &new_timeout);
> +		ohm_plugin_conf_set_key (plugin, "idle.timeout", new_timeout);
> +		ohm_plugin_conf_set_key (plugin, "timeouts.momentary", 0);
> +		ohm_plugin_conf_set_key (plugin, "timeouts.powersave", 0);
> +		ohm_plugin_conf_set_key (plugin, "timeouts.powerdown", 0);
> +		break;
> +	case 1:
> +		ohm_plugin_conf_get_key (plugin, "timeouts.timer_powersave", &new_timeout);
> +		ohm_plugin_conf_get_key (plugin, "timeouts.timer_momentary", &old_timeout);
> +		ohm_plugin_conf_set_key (plugin, "idle.timeout", new_timeout-old_timeout);
> +		ohm_plugin_conf_set_key (plugin, "timeouts.momentary", 1);
> +		break;
> +	case 2:
> +		ohm_plugin_conf_get_key (plugin, "timeouts.timer_powerdown", &new_timeout);
> +		ohm_plugin_conf_get_key (plugin, "timeouts.timer_powersave", &old_timeout);
> +		ohm_plugin_conf_set_key (plugin, "idle.timeout", new_timeout-old_timeout);
> +		ohm_plugin_conf_set_key (plugin, "timeouts.powersave", 1);
> +		break;
> +	case 3:
> +		ohm_plugin_conf_set_key (plugin, "timeouts.powerdown", 1);
> +		break;
> +	default:
> +		break;
> +	}
> +}
> +
> +OHM_PLUGIN_DESCRIPTION (
> +	"timeouts",			/* description */
> +	"0.0.1",			/* version */
> +	"rob.taylor at codethink.co.uk",	/* author */
> +	OHM_LICENSE_LGPL,		/* license */
> +	init,				/* initialize */
> +	NULL,				/* destroy */
> +	notify				/* notify */
> +);
> +
> +OHM_PLUGIN_PROVIDES (
> +	"timeouts.momentary",
> +	"timeouts.powersave",
> +	"timeouts.powerdown"
> +);
> +
> +OHM_PLUGIN_REQUIRES (
> +	"idle"
> +);
> +
> +OHM_PLUGIN_INTERESTED (
> +	{"idle.state", CONF_IDLE_STATE_CHANGED}
> +);
> diff --git a/plugins/policy/timeouts/timeouts.ini b/plugins/policy/timeouts/timeouts.ini
> new file mode 100644
> index 0000000..703385b
> --- /dev/null
> +++ b/plugins/policy/timeouts/timeouts.ini
> @@ -0,0 +1,4 @@
> +timeouts.timer_momentary 5000 public
> +timeouts.timer_powersave 10000 public
> +timeouts.timer_powerdown 100000 public
> +
> diff-tree c6b1dc765bd1f769bf8e365795f9a798e920e82d (from 3b24523a7763c76524bd965eefb73276f120ed28)
> Author: Rob Taylor <rob.taylor at codethink.co.uk>
> Date:   Sat Aug 18 15:24:58 2007 +0100
> 
>     document idle plugin usage.
>     
>     Document idle plugin usage.
> 
> diff --git a/plugins/glue/idle/README b/plugins/glue/idle/README
> index 0db68d7..b00f58d 100644
> --- a/plugins/glue/idle/README
> +++ b/plugins/glue/idle/README
> @@ -1 +1,16 @@
> -Todo
> +OHM Idle Plugin
> +---------------
> +The OHM Idle plugin is used to discover when there have been varying lengths
> +of user input inactivity.
> +
> +The idle plugin exposes 2 keys:
> + * idle.state
> + * idle.timeout
> +
> +When there is user activity, idle.state will be set to 0.
> +After idle.timeout milliseconds idle.state will be incremented.
> +
> +If a policy wishes to measure, say 2 different lengths of user inactibity, they
> +may set timeout to a new value when idle.state is incremented. When that new timout expires, idle.state will be incremented again, and so on.
> +
> +See defualt policy module 'timeouts' for an example.
> diff-tree 3b24523a7763c76524bd965eefb73276f120ed28 (from 3cbe4c4a2c85df3e8d281ffe81f5db862fb77ef9)
> Author: Rob Taylor <rob.taylor at codethink.co.uk>
> Date:   Sat Aug 18 15:18:50 2007 +0100
> 
>     modify idle plugin to use a generic interface
>     
>     Rather than making the idle plugin implement some policy (3 timeouts, momentary, powersave, powerdown), give it a generic interface that allows an arbitary number of timeouts.
> 
> diff --git a/plugins/glue/idle/idle.ini b/plugins/glue/idle/idle.ini
> index e328945..72605d6 100644
> --- a/plugins/glue/idle/idle.ini
> +++ b/plugins/glue/idle/idle.ini
> @@ -1,5 +1,4 @@
>  # idle preference values
> -idle.timer_momentary 5000 public
> -idle.timer_powersave 10000 public
> -idle.timer_powerdown 100000 public
> +idle.timeout 5000 public
> +idle.state 0 public
>  
> diff --git a/plugins/glue/idle/ohm-plugin-idle.c b/plugins/glue/idle/ohm-plugin-idle.c
> index 2990f58..1571671 100644
> --- a/plugins/glue/idle/ohm-plugin-idle.c
> +++ b/plugins/glue/idle/ohm-plugin-idle.c
> @@ -29,6 +29,7 @@ static LibIdletime *idletime = NULL;
>  
>  enum {
>  	CONF_XORG_HASXAUTH_CHANGED,
> +	CONF_IDLE_TIMEOUT_CHANGED,
>  	CONF_LAST
>  };
>  
> @@ -36,16 +37,14 @@ static void
>  ohm_alarm_expired_cb (LibIdletime *idletime, guint alarm, gpointer data)
>  {
>  	OhmPlugin *plugin = (OhmPlugin *) data;
> -	if (alarm == 0) {
> -		ohm_plugin_conf_set_key (plugin, "idle.momentary", 0);
> -		ohm_plugin_conf_set_key (plugin, "idle.powersave", 0);
> -		ohm_plugin_conf_set_key (plugin, "idle.powerdown", 0);
> -	} else if (alarm == 1) {
> -		ohm_plugin_conf_set_key (plugin, "idle.momentary", 1);
> -	} else if (alarm == 2) {
> -		ohm_plugin_conf_set_key (plugin, "idle.powersave", 1);
> -	} else if (alarm == 3) {
> -		ohm_plugin_conf_set_key (plugin, "idle.powerdown", 1);
> +	gint state;
> +
> +	if (alarm == 0 ) {
> +		/* activity, reset state to 0 */
> +		ohm_plugin_conf_set_key (plugin, "idle.state", 0);
> +	} else {
> +		ohm_plugin_conf_get_key (plugin, "idle.state", &tate);
> +		ohm_plugin_conf_set_key (plugin, "idle.state", state+1);
>  	}
>  	g_print ("[evt %i]\n", alarm);
>  }
> @@ -54,9 +53,7 @@ static void
>  plugin_connect_idletime (OhmPlugin *plugin)
>  {
>  	gboolean ret;
> -	gint momentary;
> -	gint powersave;
> -	gint powerdown;
> +	gint timeout;
>  	const gchar *xauth;
>  
>  	xauth = getenv ("XAUTHORITY");
> @@ -69,21 +66,13 @@ plugin_connect_idletime (OhmPlugin *plug
>  	g_signal_connect (idletime, "alarm-expired",
>  			  G_CALLBACK (ohm_alarm_expired_cb), plugin);
>  
> -	ohm_plugin_conf_get_key (plugin, "idle.timer_momentary", &momentary);
> -	ohm_plugin_conf_get_key (plugin, "idle.timer_powersave", &powersave);
> -	ohm_plugin_conf_get_key (plugin, "idle.timer_powerdown", &powerdown);
> +	ohm_plugin_conf_get_key (plugin, "idle.timeout", &timeout);
> +
> +	ohm_plugin_conf_set_key (plugin, "idle.state", 0);
>  
>  	ret = idletime_alarm_set (idletime, 1, momentary);
>  	if (ret == FALSE) {
> -		g_error ("cannot set alarm 1");
> -	}
> -	ret = idletime_alarm_set (idletime, 2, powersave);
> -	if (ret == FALSE) {
> -		g_error ("cannot set alarm 2");
> -	}
> -	ret = idletime_alarm_set (idletime, 3, powerdown);
> -	if (ret == FALSE) {
> -		g_error ("cannot set alarm 3");
> +		g_error ("cannot set alarm");
>  	}
>  }
>  
> @@ -123,6 +112,8 @@ plugin_notify (OhmPlugin *plugin, gint i
>  		if (value == 1) {
>  			plugin_connect_idletime (plugin);
>  		}
> +	} else if (id == CONF_IDLE_TIMEOUT_CHANGED ) {
> +		idletime_alarm_set (idletime, 1, value);
>  	}
>  }
>  static void
> @@ -144,6 +135,7 @@ OHM_PLUGIN_DESCRIPTION (
>  
>  OHM_PLUGIN_REQUIRES ("xorg");
>  
> -OHM_PLUGIN_PROVIDES ("idle.momentary", "idle.powersave", "idle.powerdown");
> +OHM_PLUGIN_PROVIDES ("idle.state", "idle.timeout");
>  
>  OHM_PLUGIN_INTERESTED ({"xorg.has_xauthority", CONF_XORG_HASXAUTH_CHANGED});
> +OHM_PLUGIN_INTERESTED ({"idle.timeout", CONF_IDLE_TIMEOUT_CHANGED});
> _______________________________________________
> Ohm-devel mailing list
> Ohm-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/ohm-devel



More information about the Ohm-devel mailing list