osmank3 / otp-keys

Show and copy otp keys on Gnome Shell panel
GNU General Public License v3.0
9 stars 5 forks source link

I can no longer access the preferences #16

Open alexaandru opened 2 days ago

alexaandru commented 2 days ago

Hello,

I am on Fedora Linux 41 (Workstation Edition) using Gnome 47 on Wayland. When I installed the extension I was on Fedora 39, then I did two system upgrades along the way. It was fine on 40, but now when I tried to access the preferences it crashes with:

Gio.DBusError: No such secret item at path: /org/freedesktop/secrets/collection/login/53

Stack trace:
  isKeyringUnlocked@file:///home/alex/.local/share/gnome-shell/extensions/otp-keys@osmank3.net/otplib.js:34:40
  _sync@file:///home/alex/.local/share/gnome-shell/extensions/otp-keys@osmank3.net/prefs.js:226:30
  OtpList@file:///home/alex/.local/share/gnome-shell/extensions/otp-keys@osmank3.net/prefs.js:140:14
  OtpRoot@file:///home/alex/.local/share/gnome-shell/extensions/otp-keys@osmank3.net/prefs.js:24:21
 fillPreferencesWindow@file:///home/alex/.local/share/gnome-shell/extensions/otp-keys@osmank3.net/prefs.js:752:23
  _loadPrefs@resource:///org/gnome/Shell/Extensions/js/extensionPrefsDialog.js:39:24
  async*_init@resource:///org/gnome/Shell/Extensions/js/extensionPrefsDialog.js:24:14
  ExtensionPrefsDialog@resource:///org/gnome/Shell/Extensions/js/extensionPrefsDialog.js:15:4
  OpenExtensionPrefsAsync@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:138:33
  async*_handleMethodCall@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:373:35
  _wrapJSObject/<@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:408:34
  _init/GLib.MainLoop.prototype.runAsync/</<@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:263:34

The app still works, I can still use the codes for logging in just fine. I just cannot open the preferences.

osmank3 commented 2 days ago

I will look into this issue when I have free time.

alexaandru commented 1 day ago

In the meantime, if anyone needs to access their preferences (and run into the same issue): I edited .local/share/gnome-shell/extensions/otp-keys@osmank3.net/extension.js and changed:

  diff --git a/extension.js b/extension.js
  index 415c0d0..60e4381 100644
  --- a/extension.js
  +++ b/extension.js
  @@ -75,8 +75,9 @@ class OtpMenuItem extends PopupMenu.PopupBaseMenuItem {
       _copyToClipboard() {
           const clipboard = St.Clipboard.get_default();
           let code = Totp.getCode(this._otp.secret, this._otp.digits, this._otp.period, this._otp.algorithm);
  -        clipboard.set_text(St.ClipboardType.PRIMARY, code);
  -        clipboard.set_text(St.ClipboardType.CLIPBOARD, code);
  +        const out = JSON.stringify({code, otp: this._otp})
  +        clipboard.set_text(St.ClipboardType.PRIMARY, out);
  +        clipboard.set_text(St.ClipboardType.CLIPBOARD, out);

           if (this._settings.get_boolean(SETTINGS_NOTIFY))
               Main.notify(_("Code copied to clipboard."), _("Copied code is: ") + code);

Now when I copy to clipboard I get both the code and the preferences together. This also proves that the preferences are fine.

osmank3 commented 1 day ago

If you want to access otp keys secrets, you can read it from seahorse(keyring).

alexaandru commented 1 day ago

Much appreciated!

alexaandru commented 1 day ago

I don't know what happend, but it is back working now. I tried it today over 10 times and it failed each time, before opening this issue. Then I just tried it now and it works, no issue. That path it errored about still does not exist:

$ dconf dump /org/freedesktop/secrets/                 
$ 

so it's not like it magically appeared, it's just that it no longer is an issue...