I am writing a gnome-shell extension that shows the current balance of prepaid-cards like phones (or electricity). As this needs credentials for the given services, I do not want to store the password in gsettings, but as entry in gnome keyring.
Currently, I use the synchronous way asking the keyring for login and password using
const GnomeKeyring = imports.gi.GnomeKeyring;
GnomeKeyring.unlock_sync(null, null)
// the variable 'id' is a concat of login '@'webservice url
var attrs = GnomeKeyring.Attribute.list_new()
GnomeKeyring.Attribute.list_append_string(attrs, 'id', id)
var result = GnomeKeyring.find_items_sync(
GnomeKeyring.ItemType.GENERIC_SECRET,
attrs
)
if (result[0] != GnomeKeyring.Result.OK) return
log(' => password '+result[1][0].secret)
log(' keyring id = '+result[1][0].item_id)
log(' keyring = '+result[1][0].keyring)
This sync. approachs weak point is, that the keyring needs to already be open or a password dialog is prompted. When starting gnome-shell with auto-login, this synchronous call blocks actually starting the shell at all - so no possibility to enter the keyring password.
The Gnome Developer Wiki names the asynchronous methods
- GnomeKeyring.unlock
- GnomeKeyring.find_items
but both are not found in the javascript environment.
Where can I find the GnomeKeyring-Gir file under fedora23 to confirm the lack of the asynch functions missing? How can I achieve an asynchronous keyring-opening and retrieve of the passwords? Does anybody see a completely different, possible approach? Every little helps...