summaryrefslogtreecommitdiff
path: root/plugins/glue
diff options
context:
space:
mode:
authorRob Taylor <rob.taylor@codethink.co.uk>2007-08-22 14:48:11 +0100
committerRob Taylor <rob.taylor@codethink.co.uk>2007-08-22 15:17:50 +0100
commit7ba694c385e62e6d668202952969c007ab364792 (patch)
tree7d96688201df0cbb259cb9e26fdcc9eda559a298 /plugins/glue
parentdae3b4dd679d9209afa9447298e8a056ebefc411 (diff)
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.
Diffstat (limited to 'plugins/glue')
-rw-r--r--plugins/glue/idle/ohm-plugin-idle.c30
1 files changed, 18 insertions, 12 deletions
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 *plugin)
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 id, gint value)
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},