I'm writing an application for the Ubuntu app showdown and I try to read/write the user's profile picture using this
>>> from gi.repository import AccountsService, GLib
>>> current_user = GLib.get_user_name()
>>> user = AccountsService.UserManager.get_default().get_user(current_user)
>>> print user.get_icon_file()
None
>>> print user.get_user_name()
None
But apparently does not work. Is there another way to use AccountsService with Python?
I could not find more documentation about AccountsService and Python.
PS: to test this example you need to install gir1.2-accountsservice-1.0
on Ubuntu 12.04.
$ sudo apt-get install gir1.2-accountsservice-1.0
Best Answer
After looking at the source to libaccountsservice you actually have to wait for the user to be loaded before accessing the user object. This acheives the result:
Alternatively, you can contact the accounts service directly and synchronously over D-Bus:
If you want to set the icon file you need to call the appropriate method:
If you need to use any other methods, browse the D-Bus interface using D-Feet (in the software center).