I've been trying to change the background image of pantheon-greeter. It should change on the depending user. After browsing the code base of pantheon greeter if found that they get the background image from the method LightDM.User.get_background ()
. Is that the right way? If it is so how can I change the user specific background with Vala?
Add a comment
|
1 Answer
I've found a solution in the official code of the elementary settings app.
[DBus (name = "org.freedesktop.Accounts.User")]
interface AccountsServiceUser : Object {
public abstract void set_background_file (string filename) throws IOError;
}
Define Dbus and declare the private member on your class
//Instance of the AccountsServices-Interface for this user
private AccountsServiceUser accountsservice = null;
and the implementation
try {
string uid = "%d".printf ((int) Posix.getuid ());
accountsservice = Bus.get_proxy_sync (BusType.SYSTEM,
"org.freedesktop.Accounts",
"/org/freedesktop/Accounts/User" + uid);
} catch (Error e) {
warning (e.message);
}
is actually what is needed. So you can call
accountsservice.set_background_file (path);
For more information about the implementation look in the source of the switchboard project of Elementary at launchpad