Re: [systemd-devel] interacting with logind to detect user idle time

2019-05-23 Thread Germano Massullo
I have sent the following message to various desktop environment mailing lists

SUBJECT: Proposal: passing user idle time to systemd-logind
KDE Plasma: https://mail.kde.org/pipermail/plasma-devel/2019-May/098194.html
GNOME: https://mail.gnome.org/archives/desktop-devel-list/2019-May/msg00088.html
XFCE https://mail.xfce.org/pipermail/xfce4-dev/2019-May/032257.html
LXDE: https://sourceforge.net/p/lxde/mailman/message/36674273/
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] interacting with logind to detect user idle time

2019-05-22 Thread Germano Massullo
Il giorno mer 22 mag 2019 alle ore 11:41 Mantas Mikulėnas
 ha scritto:
> On Wed, May 22, 2019, 12:37 Germano Massullo  
> wrote:
>> Second question: perhaps can be useful if I start a topic in GNOME /
>> KDE Plasma development mailing lists asking them to make patches that
>> will let systemd-logind know about user idle time. By doing this,
>> Linux distro world could use systemd-logind as single solution for
>> detecting user idle time, making easier the work of third party
>> developers
>
> Hmm, doesn't GNOME 3 already do this?

Seem to not doing it because the properties
IdleSinceHint
IdleSinceHintMonotonic
are always equal to zero even on GNOME 3
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] interacting with logind to detect user idle time

2019-05-22 Thread Mantas Mikulėnas
On Wed, May 22, 2019, 12:37 Germano Massullo 
wrote:

> Il giorno mer 22 mag 2019 alle ore 11:17 Mantas Mikulėnas
>  ha scritto:
> > If your program is already X11-based, you could use the screensaver
> protocol to get idle status and forward it to logind.
>
> BOINC client is just a service, and it runs on machines that can run
> X11, Wayland, or no graphical session.
> So if with screensaver protocol you meant XScreensaver API, this
> unfortunately will not fit my needs. Perhaps instead of using a single
> solution for all of them I have to write some code that will adapt at
> least to the main desktop environments, by asking to them the user
> idle time.
>

Better to have a small 'agent' program that runs within the desktop
environment and reports idleness to logind like the DE is supposed to.

That program would be able to use X11 to determine session idleness, and
it'd work for all DEs and wouldn't be limited to BOINC either.

Having BOINC itself dig into the internals of every DE is ... not optimal.


> Second question: perhaps can be useful if I start a topic in GNOME /
> KDE Plasma development mailing lists asking them to make patches that
> will let systemd-logind know about user idle time. By doing this,
> Linux distro world could use systemd-logind as single solution for
> detecting user idle time, making easier the work of third party
> developers
>

Hmm, doesn't GNOME 3 already do this?


___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] interacting with logind to detect user idle time

2019-05-22 Thread Germano Massullo
Il giorno mer 22 mag 2019 alle ore 11:17 Mantas Mikulėnas
 ha scritto:
> If your program is already X11-based, you could use the screensaver protocol 
> to get idle status and forward it to logind.

BOINC client is just a service, and it runs on machines that can run
X11, Wayland, or no graphical session.
So if with screensaver protocol you meant XScreensaver API, this
unfortunately will not fit my needs. Perhaps instead of using a single
solution for all of them I have to write some code that will adapt at
least to the main desktop environments, by asking to them the user
idle time.

Second question: perhaps can be useful if I start a topic in GNOME /
KDE Plasma development mailing lists asking them to make patches that
will let systemd-logind know about user idle time. By doing this,
Linux distro world could use systemd-logind as single solution for
detecting user idle time, making easier the work of third party
developers
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] interacting with logind to detect user idle time

2019-05-22 Thread Mantas Mikulėnas
On Wed, May 22, 2019, 12:13 Germano Massullo 
wrote:

> 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?
>

Those desktop environments just do not set the IdleHint at all.

(Logind on its own cannot determine idleness "from the outside", it relies
on the DE to pass this information.)

If your program is already X11-based, you could use the screensaver
protocol to get idle status and forward it to logind.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] interacting with logind to detect user idle time

2019-05-22 Thread Germano Massullo
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 

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)", _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
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] interacting with logind to detect user idle time

2019-05-17 Thread Germano Massullo
Perfect, thank you very much!
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] interacting with logind to detect user idle time

2019-05-17 Thread Lennart Poettering
On Do, 16.05.19 17:12, Germano Massullo (germano.massu...@gmail.com) wrote:

> To do practise I am using NetworkManager example [1]
> All macros passed as arguments to functions
> g_dbus_proxy_call_sync
> g_dbus_proxy_new_for_bus_sync
> are implemented at [2].
> Is there an equivalent of [2] for logind? I made a quick search into
> systemd repository [3] but I am getting too many results with the
> search words I am using. I just need to figure out what parameters I
> have to pass to the previous functions in order to retrieve
> IdleSinceHint property

If you are looking for some help regarding gdbus, it's probably best
to inquire on some gdbus/glib mailing list.

With the "busctl" tool you can read the propery with a command like
the following:

busctl get-property org.freedesktop.login1 /org/freedesktop/login1/session/_31 
org.freedesktop.login1.Session IdleSinceHint

I am sure the gdbus folks will be able to give you the right hints how
to do the same with native gdbus API calls quickly if you ask them for
the equivalent of the above line.

Lennart

--
Lennart Poettering, Berlin
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] interacting with logind to detect user idle time

2019-05-16 Thread Germano Massullo
To do practise I am using NetworkManager example [1]
All macros passed as arguments to functions
g_dbus_proxy_call_sync
g_dbus_proxy_new_for_bus_sync
are implemented at [2].
Is there an equivalent of [2] for logind? I made a quick search into
systemd repository [3] but I am getting too many results with the
search words I am using. I just need to figure out what parameters I
have to pass to the previous functions in order to retrieve
IdleSinceHint property

Thank you for your time

[1]: 
https://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/C/glib/list-connections-gdbus.c
[2]: 
https://github.com/NetworkManager/NetworkManager/blob/master/libnm-core/nm-dbus-interface.h
[3]: https://github.com/systemd/systemd
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] interacting with logind to detect user idle time

2019-05-14 Thread Lennart Poettering
On Di, 14.05.19 11:32, Germano Massullo (germano.massu...@gmail.com) wrote:

> Il giorno lun 13 mag 2019 alle ore 10:00 Lennart Poettering
>  ha scritto:
> > Note that it only works correctly on desktops that support it.
>
> Thank you for your reply. Why does it work only on desktop
> environments that support it? I believed that it provides idle infos
> to the D.E. not viceversa
> According to this seems that it would not be able to detect user idle
> time on headless systems where users generally operate by SSH.

Desktop environments need to tell us when the user last did something,
if they don#t we really don't know.

For tty logins we can watch the last access time of the tty to know
when the user last did something. inotify will notify us about that
nicely.

Lennart

--
Lennart Poettering, Berlin
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] interacting with logind to detect user idle time

2019-05-14 Thread Germano Massullo
Il giorno lun 13 mag 2019 alle ore 10:00 Lennart Poettering
 ha scritto:
> Note that it only works correctly on desktops that support it.

Thank you for your reply. Why does it work only on desktop
environments that support it? I believed that it provides idle infos
to the D.E. not viceversa
According to this seems that it would not be able to detect user idle
time on headless systems where users generally operate by SSH.

Have a nice day
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Re: [systemd-devel] interacting with logind to detect user idle time

2019-05-13 Thread Lennart Poettering
On Mi, 08.05.19 14:37, Germano Massullo (germano.massu...@gmail.com) wrote:

> Hi, I am doing some practice with writing software using GDBus API. I
> need it to implement on BOINC client, user(s) idle time detection by
> retrieving such info from logind.
> In order to retrieve user idle time I was thinking of using the
> property IdleSinceHint. What do you think about?

Yes, it tells you about the time logind thinks a session has been
idle. Note that it only works correctly on desktops that support it.

Lennart

--
Lennart Poettering, Berlin
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

[systemd-devel] interacting with logind to detect user idle time

2019-05-08 Thread Germano Massullo
Hi, I am doing some practice with writing software using GDBus API. I
need it to implement on BOINC client, user(s) idle time detection by
retrieving such info from logind.
In order to retrieve user idle time I was thinking of using the
property IdleSinceHint. What do you think about?

Best regards
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel