From 92264ac2b96676b6bcb2d13f7aa2620fe2193582 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Fri, 3 May 2024 22:43:28 +0200 Subject: [PATCH] Add resource json --- gui/src/gui/browserbiometrics.py | 5 ++++- gui/src/gui/login.py | 2 +- gui/src/gui/pinentry.py | 2 +- gui/src/gui/pinentry_approval.py | 2 +- gui/src/gui/quickaccess.py | 2 +- gui/src/gui/{template_loader.py => resource_loader.py} | 6 ++++++ gui/src/gui/resources/commands.json | 5 +++++ gui/src/gui/settings.py | 2 +- gui/src/gui/shortcuts.py | 2 +- gui/src/gui/ssh.py | 7 ++++++- 10 files changed, 27 insertions(+), 8 deletions(-) rename gui/src/gui/{template_loader.py => resource_loader.py} (64%) create mode 100644 gui/src/gui/resources/commands.json diff --git a/gui/src/gui/browserbiometrics.py b/gui/src/gui/browserbiometrics.py index 289f1b1..3b4414b 100644 --- a/gui/src/gui/browserbiometrics.py +++ b/gui/src/gui/browserbiometrics.py @@ -8,7 +8,7 @@ gi.require_version('Adw', '1') from gi.repository import Gtk, Adw, GLib, Gdk, Gio from ..services import goldwarden from threading import Thread -from .template_loader import load_template +from .resource_loader import load_template, load_json import subprocess from . import components import os @@ -26,6 +26,9 @@ class GoldwardenBrowserBiometricsSetupGuideApp(Adw.Application): builder = load_template("browserbiometrics.ui") self.window = builder.get_object("window") self.window.set_application(self) + commands = load_json("commands") + self.setup_command_row = builder.get_object("setup_command_row") + self.setup_command_row.set_subtitle(commands["browserbiometric-setup"]) if __name__ == "__main__": app = GoldwardenBrowserBiometricsSetupGuideApp(application_id="com.quexten.Goldwarden.browserbiometrics") diff --git a/gui/src/gui/login.py b/gui/src/gui/login.py index a062b1a..0a8179b 100644 --- a/gui/src/gui/login.py +++ b/gui/src/gui/login.py @@ -5,7 +5,7 @@ import gc import time from gi.repository import Gtk, Adw, GLib, Notify, Gdk from threading import Thread -from .template_loader import load_template +from .resource_loader import load_template import sys import os from ..services import goldwarden diff --git a/gui/src/gui/pinentry.py b/gui/src/gui/pinentry.py index 8cb8b8c..d2391a4 100644 --- a/gui/src/gui/pinentry.py +++ b/gui/src/gui/pinentry.py @@ -5,7 +5,7 @@ import gc import time from gi.repository import Gtk, Adw, GLib, Notify, Gdk from threading import Thread -from .template_loader import load_template +from .resource_loader import load_template import sys import os diff --git a/gui/src/gui/pinentry_approval.py b/gui/src/gui/pinentry_approval.py index 0ecff53..cb2c5e8 100644 --- a/gui/src/gui/pinentry_approval.py +++ b/gui/src/gui/pinentry_approval.py @@ -5,7 +5,7 @@ import gc import time from gi.repository import Gtk, Adw, GLib, Notify, Gdk from threading import Thread -from .template_loader import load_template +from .resource_loader import load_template import sys import os diff --git a/gui/src/gui/quickaccess.py b/gui/src/gui/quickaccess.py index 9ed95e7..ac21fcb 100644 --- a/gui/src/gui/quickaccess.py +++ b/gui/src/gui/quickaccess.py @@ -7,7 +7,7 @@ import time from gi.repository import Gtk, Adw, GLib, Notify, Gdk from ..services import goldwarden from threading import Thread -from .template_loader import load_template +from .resource_loader import load_template import sys import os from ..services import totp diff --git a/gui/src/gui/template_loader.py b/gui/src/gui/resource_loader.py similarity index 64% rename from gui/src/gui/template_loader.py rename to gui/src/gui/resource_loader.py index 65c0a8c..6c04d4c 100644 --- a/gui/src/gui/template_loader.py +++ b/gui/src/gui/resource_loader.py @@ -1,5 +1,6 @@ import os from gi.repository import Gtk +import json isflatpak = os.path.exists("/.flatpak-info") pathprefix = "/app/bin/src/gui/" if isflatpak else "./src/gui/" @@ -8,3 +9,8 @@ def load_template(path): builder = Gtk.Builder() builder.add_from_file(pathprefix + ".templates/" + path) return builder + +def load_json(name): + with open(pathprefix + "resources/" + name + ".json", "r") as f: + result = json.load(f) + return result \ No newline at end of file diff --git a/gui/src/gui/resources/commands.json b/gui/src/gui/resources/commands.json new file mode 100644 index 0000000..cf323cc --- /dev/null +++ b/gui/src/gui/resources/commands.json @@ -0,0 +1,5 @@ +{ + "browserbiometric-setup": "flatpak run --filesystem=home --command=goldwarden com.quexten.Goldwarden setup browserbiometrics", + "add-ssh-key": "flatpak run --command=goldwarden com.quexten.Goldwarden ssh add --name MY_KEY_NAME", + "ssh-socket-path": "export SSH_AUTH_SOCK=/home/$USER/.var/app/com.quexten.Goldwarden/data/ssh-auth-sock" +} \ No newline at end of file diff --git a/gui/src/gui/settings.py b/gui/src/gui/settings.py index 69ada13..c37a126 100644 --- a/gui/src/gui/settings.py +++ b/gui/src/gui/settings.py @@ -8,7 +8,7 @@ gi.require_version('Adw', '1') from gi.repository import Gtk, Adw, GLib, Gdk, Gio from ..services import goldwarden from threading import Thread -from .template_loader import load_template +from .resource_loader import load_template import subprocess import os diff --git a/gui/src/gui/shortcuts.py b/gui/src/gui/shortcuts.py index 68b824f..8c9eb49 100644 --- a/gui/src/gui/shortcuts.py +++ b/gui/src/gui/shortcuts.py @@ -8,7 +8,7 @@ gi.require_version('Adw', '1') from gi.repository import Gtk, Adw, GLib, Gdk, Gio from ..services import goldwarden from threading import Thread -from .template_loader import load_template +from .resource_loader import load_template import subprocess from . import components import os diff --git a/gui/src/gui/ssh.py b/gui/src/gui/ssh.py index 3681997..e0c1f49 100644 --- a/gui/src/gui/ssh.py +++ b/gui/src/gui/ssh.py @@ -8,7 +8,7 @@ gi.require_version('Adw', '1') from gi.repository import Gtk, Adw, GLib, Gdk, Gio from ..services import goldwarden from threading import Thread -from .template_loader import load_template +from .resource_loader import load_template, load_json import subprocess from . import components import os @@ -26,6 +26,11 @@ class GoldwardenSSHSetupGuideApp(Adw.Application): builder = load_template("ssh.ui") self.window = builder.get_object("window") self.window.set_application(self) + commands = load_json("commands") + self.add_ssh_key_row = builder.get_object("add_ssh_key_row") + self.add_ssh_key_row.set_subtitle(commands["add-ssh-key"]) + self.ssh_socket_path_row = builder.get_object("ssh_socket_path_row") + self.ssh_socket_path_row.set_subtitle(commands["ssh-socket-path"]) if __name__ == "__main__": app = GoldwardenSSHSetupGuideApp(application_id="com.quexten.Goldwarden.sshsetup")