Good day.
I have noticed that on many Linux distributions with different desktop
environments, the properties
IdleSinceHint
IdleSinceHintMonotonic
are always equal to zero. This happens even if you try to use a sleep
in order to simulate a kind of user inactivity.
What is this happening?
I have written a little piece of code that is able to print on
standard output the IdleSinceHint
Thank you!
/*
* Compile with:
* gcc -Wall print_user_idle_time.c -o print_user_idle_time `pkg-config --libs gio-2.0 --cflags`
*/
#include <gio/gio.h>
static void
print_user_idle_time (GDBusProxy *proxy)
{
guint64 user_idle_time;
gchar *property = "IdleSinceHint";
GError *error = NULL;
GVariant *ret = NULL;
sleep(2);
ret = g_dbus_proxy_get_cached_property(proxy, property);
if (!ret) {
g_dbus_error_strip_remote_error (error);
g_print ("IdleSinceHint failed: %s\n", error->message);
g_error_free (error);
return;
}
user_idle_time = g_variant_get_uint64 (ret);
/*
/g_variant_get (ret, "(^ao)", &user_idle_time);
has been replaced with
user_idle_time = g_variant_get_uint64 (ret);
*/
g_print("%lu\n", user_idle_time);
g_variant_unref (ret);
}
int
main (int argc, char *argv[])
{
GDBusProxy *proxy = NULL;
gchar *name = "org.freedesktop.login1";
gchar *object_path = "/org/freedesktop/login1";
gchar *interface_name = "org.freedesktop.login1.Manager";
/* Create a D-Bus proxy */
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
name,
object_path,
interface_name,
NULL, NULL);
g_assert (proxy != NULL);
print_user_idle_time (proxy);
g_object_unref (proxy);
return 0;
}
_______________________________________________
systemd-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/systemd-devel