How to get account email?

In the Settings / Users I can edit my details and add an email address. But how can I get it from a script?

I found that it’s saved to the file /var/lib/AccountsService/users/myuser:

[User]
Email=myuser@example.com
Languages=en_US;
Session=
FormatsLocale=fi_FI.UTF-8
Icon=/var/lib/AccountsService/icons/myuser
SystemAccount=false

The file is created by the accountsservice package from the FreeDesktop:

In sources I found that it have a DBus interface: /usr/share/dbus-1/interfaces/org.freedesktop.Accounts.xml.

I may try to call dbus but this is too complicated. Maybe there is some easier way?
For example to get a user’s full name we can use the pinky -l myuser (finger from coreutils) or even parse the /etc/passwd file. Maybe there is some simpler way to do this?
I didn’t used ActiveDirectory but as far I know it should be possible to get user details. Maybe you know how it’s implemented there?

Some of these services have a CLI tool for interacting with it, e.g. systemctl for systemd

No idea if this is applicable here.

D-Bus would be

qdbus6 --system org.freedesktop.Accounts /org/freedesktop/Accounts/User$UID org.freedesktop.DBus.Properties.Get org.freedesktop.Accounts.User Email
1 Like

Thank you, I hope eventually this will become easier