From ab0a0c30dbac4b0594ee2a55ed286201c559e3bc Mon Sep 17 00:00:00 2001 From: Recolic Keghart <root@recolic.net> Date: Thu, 9 May 2019 02:36:51 -0700 Subject: [PATCH] add a tiny tool --- README.md | 6 ++++++ src/unlock_keyrings.cc | 4 ++-- tools/list_keyrings.cc | 14 ++++++++++++++ tools/list_keyrings.sh | 4 ++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 tools/list_keyrings.cc create mode 100755 tools/list_keyrings.sh diff --git a/README.md b/README.md index 56e69e2..185c242 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,12 @@ Then, add the following command to gnome-autostart. You should know how to auto- You're all set! Re-login and have a try! +## FAQ + +- Keyring not exist? The name is correct. + +run `tools/list_keyrings.sh` to check name of your keyrings. The `login` keyring may be shown as `登录` based on your locale. + ## TODO This program is using deprecated `libgnome-keyring-1` rather than `libsecret`, only because the author can not understand how to use `libsecret`. There's almost no document! (If you think auto-generated document is document, then all source code are well documented. ) diff --git a/src/unlock_keyrings.cc b/src/unlock_keyrings.cc index 8e829ae..d17b663 100644 --- a/src/unlock_keyrings.cc +++ b/src/unlock_keyrings.cc @@ -43,9 +43,9 @@ int main(int argc, char **argv) { auto res = do_unlock(keyring_and_pswd.at(0), keyring_and_pswd.at(1)); auto msg = keyringResultToString(res); if(res == GNOME_KEYRING_RESULT_OK) - rlog.info("line {}: {}.", line_num, msg); + rlog.info("line {}: Working on keyring `{}`: {}.", line_num, keyring_and_pswd.at(0), msg); else { - rlog.error("line {}: {}.", line_num, msg); + rlog.error("line {}: Working on keyring `{}`: {}.", line_num, keyring_and_pswd.at(0), msg); no_error = false; } diff --git a/tools/list_keyrings.cc b/tools/list_keyrings.cc new file mode 100644 index 0000000..7696695 --- /dev/null +++ b/tools/list_keyrings.cc @@ -0,0 +1,14 @@ +// You can use this naive program to know keyring names. +// eval g++ (pkg-config --cflags --libs gnome-keyring-1) list.cc -o s +#include <gnome-keyring-1/gnome-keyring.h> +#include <iostream> + +int main() { + GList *pRes = nullptr; + GnomeKeyringResult res = gnome_keyring_list_keyring_names_sync(&pRes); + for(int i = 0; i < g_list_length(pRes); ++i) { + gpointer dat = g_list_nth_data(pRes, i); + gchar *gs = (gchar *)dat; + std::cout << gs << std::endl; + } +} diff --git a/tools/list_keyrings.sh b/tools/list_keyrings.sh new file mode 100755 index 0000000..bb206f4 --- /dev/null +++ b/tools/list_keyrings.sh @@ -0,0 +1,4 @@ +#!/bin/bash +eval g++ $(pkg-config --cflags --libs gnome-keyring-1) list_keyrings.cc -o list.out && +./list.out + -- GitLab