Add resource json

This commit is contained in:
Bernd Schoolmann 2024-05-03 22:43:28 +02:00
parent 5ec0be098d
commit d960c8f122
No known key found for this signature in database
10 changed files with 27 additions and 8 deletions

View File

@ -8,7 +8,7 @@ gi.require_version('Adw', '1')
from gi.repository import Gtk, Adw, GLib, Gdk, Gio from gi.repository import Gtk, Adw, GLib, Gdk, Gio
from ..services import goldwarden from ..services import goldwarden
from threading import Thread from threading import Thread
from .template_loader import load_template from .resource_loader import load_template, load_json
import subprocess import subprocess
from . import components from . import components
import os import os
@ -26,6 +26,9 @@ class GoldwardenBrowserBiometricsSetupGuideApp(Adw.Application):
builder = load_template("browserbiometrics.ui") builder = load_template("browserbiometrics.ui")
self.window = builder.get_object("window") self.window = builder.get_object("window")
self.window.set_application(self) 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__": if __name__ == "__main__":
app = GoldwardenBrowserBiometricsSetupGuideApp(application_id="com.quexten.Goldwarden.browserbiometrics") app = GoldwardenBrowserBiometricsSetupGuideApp(application_id="com.quexten.Goldwarden.browserbiometrics")

View File

@ -5,7 +5,7 @@ import gc
import time import time
from gi.repository import Gtk, Adw, GLib, Notify, Gdk from gi.repository import Gtk, Adw, GLib, Notify, Gdk
from threading import Thread from threading import Thread
from .template_loader import load_template from .resource_loader import load_template
import sys import sys
import os import os
from ..services import goldwarden from ..services import goldwarden

View File

@ -5,7 +5,7 @@ import gc
import time import time
from gi.repository import Gtk, Adw, GLib, Notify, Gdk from gi.repository import Gtk, Adw, GLib, Notify, Gdk
from threading import Thread from threading import Thread
from .template_loader import load_template from .resource_loader import load_template
import sys import sys
import os import os

View File

@ -5,7 +5,7 @@ import gc
import time import time
from gi.repository import Gtk, Adw, GLib, Notify, Gdk from gi.repository import Gtk, Adw, GLib, Notify, Gdk
from threading import Thread from threading import Thread
from .template_loader import load_template from .resource_loader import load_template
import sys import sys
import os import os

View File

@ -7,7 +7,7 @@ import time
from gi.repository import Gtk, Adw, GLib, Notify, Gdk from gi.repository import Gtk, Adw, GLib, Notify, Gdk
from ..services import goldwarden from ..services import goldwarden
from threading import Thread from threading import Thread
from .template_loader import load_template from .resource_loader import load_template
import sys import sys
import os import os
from ..services import totp from ..services import totp

View File

@ -1,5 +1,6 @@
import os import os
from gi.repository import Gtk from gi.repository import Gtk
import json
isflatpak = os.path.exists("/.flatpak-info") isflatpak = os.path.exists("/.flatpak-info")
pathprefix = "/app/bin/src/gui/" if isflatpak else "./src/gui/" pathprefix = "/app/bin/src/gui/" if isflatpak else "./src/gui/"
@ -8,3 +9,8 @@ def load_template(path):
builder = Gtk.Builder() builder = Gtk.Builder()
builder.add_from_file(pathprefix + ".templates/" + path) builder.add_from_file(pathprefix + ".templates/" + path)
return builder return builder
def load_json(name):
with open(pathprefix + "resources/" + name + ".json", "r") as f:
result = json.load(f)
return result

View File

@ -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"
}

View File

@ -8,7 +8,7 @@ gi.require_version('Adw', '1')
from gi.repository import Gtk, Adw, GLib, Gdk, Gio from gi.repository import Gtk, Adw, GLib, Gdk, Gio
from ..services import goldwarden from ..services import goldwarden
from threading import Thread from threading import Thread
from .template_loader import load_template from .resource_loader import load_template
import subprocess import subprocess
import os import os

View File

@ -8,7 +8,7 @@ gi.require_version('Adw', '1')
from gi.repository import Gtk, Adw, GLib, Gdk, Gio from gi.repository import Gtk, Adw, GLib, Gdk, Gio
from ..services import goldwarden from ..services import goldwarden
from threading import Thread from threading import Thread
from .template_loader import load_template from .resource_loader import load_template
import subprocess import subprocess
from . import components from . import components
import os import os

View File

@ -8,7 +8,7 @@ gi.require_version('Adw', '1')
from gi.repository import Gtk, Adw, GLib, Gdk, Gio from gi.repository import Gtk, Adw, GLib, Gdk, Gio
from ..services import goldwarden from ..services import goldwarden
from threading import Thread from threading import Thread
from .template_loader import load_template from .resource_loader import load_template, load_json
import subprocess import subprocess
from . import components from . import components
import os import os
@ -26,6 +26,11 @@ class GoldwardenSSHSetupGuideApp(Adw.Application):
builder = load_template("ssh.ui") builder = load_template("ssh.ui")
self.window = builder.get_object("window") self.window = builder.get_object("window")
self.window.set_application(self) 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__": if __name__ == "__main__":
app = GoldwardenSSHSetupGuideApp(application_id="com.quexten.Goldwarden.sshsetup") app = GoldwardenSSHSetupGuideApp(application_id="com.quexten.Goldwarden.sshsetup")