diff --git a/src/main.c b/src/main.c index 8e21763..ff0d355 100644 --- a/src/main.c +++ b/src/main.c @@ -58,6 +58,8 @@ #include "orage-dbus.h" #endif +#include + /* session client handler */ /* static SessionClient *session_client = NULL; @@ -500,6 +502,35 @@ static void mark_orage_alive(void) , G_CALLBACK(client_message_received), NULL); } +static void resuming_cb(DBusGProxy *proxy, gpointer user_data) +{ + orage_message(10, "Resuming"); + orage_day_change(NULL); +} + +static void handle_resuming(void) +{ + DBusGConnection *connection; + GError *error = NULL; + DBusGProxy *proxy; + g_type_init(); + connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); + if (connection) { + proxy = dbus_g_proxy_new_for_name(connection, "org.freedesktop.UPower", + "/org/freedesktop/UPower", "org.freedesktop.UPower"); + if (proxy) { + dbus_g_proxy_add_signal(proxy, "Resuming", G_TYPE_INVALID); + dbus_g_proxy_connect_signal(proxy, "Resuming", + G_CALLBACK(resuming_cb), NULL, NULL); + } else { + g_warning("Failed to create proxy object\n"); + } + } else { + g_warning("Failed to connect to the D-BUS daemon: %s\n", + error->message); + } +} + int main(int argc, char *argv[]) { gboolean running, initialized = FALSE; @@ -575,6 +606,9 @@ int main(int argc, char *argv[]) initialized = TRUE; process_args(argc, argv, running, initialized); + /* day change after resuming */ + handle_resuming(); + gtk_main(); keep_tidy(); return(EXIT_SUCCESS);