mirror of
https://github.com/quexten/goldwarden.git
synced 2024-09-11 11:15:41 +03:00
Add ui functionality
This commit is contained in:
parent
6f30d75b08
commit
5a41145d4b
28
com.quexten.Goldwarden.yml
Normal file
28
com.quexten.Goldwarden.yml
Normal file
@ -0,0 +1,28 @@
|
||||
id: com.quexten.Goldwarden
|
||||
runtime: org.gnome.Platform
|
||||
runtime-version: '45'
|
||||
sdk: org.gnome.Sdk
|
||||
command: main.py
|
||||
finish-args:
|
||||
- --share=ipc
|
||||
- --share=network
|
||||
- --socket=wayland
|
||||
- --socket=fallback-x11
|
||||
- --filesystem=home
|
||||
modules:
|
||||
- name: goldwarden
|
||||
buildsystem: simple
|
||||
build-options:
|
||||
build-args:
|
||||
- "--share=network"
|
||||
build-commands:
|
||||
- pip3 install --prefix=/app timeago secretstorage pycryptodome chacha20
|
||||
- install -D main.py /app/bin/main.py
|
||||
- install -D com.quexten.Goldwarden.desktop /app/share/applications/com.quexten.Goldwarden.desktop
|
||||
- install -D goldwarden.svg /app/share/icons/hicolor/scalable/apps/com.quexten.Goldwarden.svg
|
||||
- cp -R ui/ /app/bin/gui/
|
||||
- cp -R backend/ /app/bin/backend/
|
||||
- cp -R event_monitors/ /app/bin/event_monitors/
|
||||
sources:
|
||||
- type: dir
|
||||
path: ui
|
10
ui/com.quexten.Goldwarden.desktop
Normal file
10
ui/com.quexten.Goldwarden.desktop
Normal file
@ -0,0 +1,10 @@
|
||||
[Desktop Entry]
|
||||
Name=Goldwarden
|
||||
Comment=A Bitwarden compatible desktop password manager
|
||||
Keywords=backup;recovery;
|
||||
Exec=main.py
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Icon=com.quexten.goldwarden.svg
|
||||
StartupNotify=true
|
||||
Categories=GNOME;GTK;Password Manager;
|
@ -45,12 +45,12 @@ def login_passwordless(email):
|
||||
raise Exception("Failed to initialize repository, err", result.stderr)
|
||||
|
||||
def is_pin_enabled():
|
||||
restic_cmd = f"{BINARY_PATH} vault pin"
|
||||
restic_cmd = f"{BINARY_PATH} vault pin status"
|
||||
result = subprocess.run(restic_cmd.split(), capture_output=True, text=True)
|
||||
if result.returncode != 0:
|
||||
raise Exception("Failed to initialize repository, err", result.stderr)
|
||||
# check if contains enabled
|
||||
return "enabled" in result.stdout
|
||||
return "enabled" in result.stderr
|
||||
|
||||
def enable_pin():
|
||||
restic_cmd = f"{BINARY_PATH} vault pin set"
|
||||
@ -58,6 +58,24 @@ def enable_pin():
|
||||
if result.returncode != 0:
|
||||
raise Exception("Failed to initialize repository, err", result.stderr)
|
||||
|
||||
def unlock():
|
||||
restic_cmd = f"{BINARY_PATH} vault unlock"
|
||||
result = subprocess.run(restic_cmd.split(), capture_output=True, text=True)
|
||||
if result.returncode != 0:
|
||||
raise Exception("Failed to initialize repository, err", result.stderr)
|
||||
|
||||
def lock():
|
||||
restic_cmd = f"{BINARY_PATH} vault lock"
|
||||
result = subprocess.run(restic_cmd.split(), capture_output=True, text=True)
|
||||
if result.returncode != 0:
|
||||
raise Exception("Failed to initialize repository, err", result.stderr)
|
||||
|
||||
def purge():
|
||||
restic_cmd = f"{BINARY_PATH} vault purge"
|
||||
result = subprocess.run(restic_cmd.split(), capture_output=True, text=True)
|
||||
if result.returncode != 0:
|
||||
raise Exception("Failed to initialize repository, err", result.stderr)
|
||||
|
||||
def get_vault_status():
|
||||
restic_cmd = f"{BINARY_PATH} vault status"
|
||||
result = subprocess.run(restic_cmd.split(), capture_output=True, text=True)
|
||||
|
25
ui/main.py
25
ui/main.py
@ -137,7 +137,7 @@ class SettingsWinvdow(Gtk.ApplicationWindow):
|
||||
|
||||
self.autofill_row = Adw.ActionRow()
|
||||
self.autofill_row.set_title("Autofill Shortcut")
|
||||
self.autofill_row.set_subtitle("Unavailable")
|
||||
self.autofill_row.set_subtitle("Unavailable, please set up a shortcut in your desktop environment (README)")
|
||||
self.preferences_group.add(self.autofill_row)
|
||||
|
||||
self.status_row = Adw.ActionRow()
|
||||
@ -163,6 +163,7 @@ class SettingsWinvdow(Gtk.ApplicationWindow):
|
||||
self.login_button = Gtk.Button()
|
||||
self.login_button.set_label("Login")
|
||||
self.login_button.connect("clicked", lambda button: show_login())
|
||||
self.login_button.set_sensitive(False)
|
||||
self.login_button.set_margin_top(10)
|
||||
self.preferences_group.add(self.login_button)
|
||||
|
||||
@ -173,18 +174,38 @@ class SettingsWinvdow(Gtk.ApplicationWindow):
|
||||
set_pin_thread.start()
|
||||
self.set_pin_button.connect("clicked", lambda button: set_pin())
|
||||
self.set_pin_button.set_margin_top(10)
|
||||
self.set_pin_button.set_sensitive(False)
|
||||
self.preferences_group.add(self.set_pin_button)
|
||||
|
||||
self.unlock_button = Gtk.Button()
|
||||
self.unlock_button.set_label("Unlock")
|
||||
self.unlock_button.set_margin_top(10)
|
||||
def unlock_button_clicked():
|
||||
action = goldwarden.unlock if self.unlock_button.get_label() == "Unlock" else goldwarden.lock
|
||||
unlock_thread = Thread(target=action)
|
||||
unlock_thread.start()
|
||||
self.unlock_button.connect("clicked", lambda button: unlock_button_clicked())
|
||||
# set disabled
|
||||
self.unlock_button.set_sensitive(False)
|
||||
self.preferences_group.add(self.unlock_button)
|
||||
|
||||
self.logout_button = Gtk.Button()
|
||||
self.logout_button.set_label("Logout")
|
||||
self.logout_button.set_margin_top(10)
|
||||
self.logout_button.connect("clicked", lambda button: goldwarden.purge())
|
||||
self.preferences_group.add(self.logout_button)
|
||||
|
||||
def update_labels():
|
||||
pin_set = goldwarden.is_pin_enabled()
|
||||
status = goldwarden.get_vault_status()
|
||||
self.status_row.set_subtitle(str("Unlocked" if status["locked"] == False else "Locked"))
|
||||
locked = status["locked"]
|
||||
self.login_button.set_sensitive(pin_set and not locked)
|
||||
self.set_pin_button.set_sensitive(not pin_set or not locked)
|
||||
self.status_row.set_subtitle(str("Unlocked" if not locked else "Locked"))
|
||||
self.login_row.set_subtitle(str(status["loginEntries"]))
|
||||
self.notes_row.set_subtitle(str(status["noteEntries"]))
|
||||
self.unlock_button.set_sensitive(True)
|
||||
self.unlock_button.set_label("Unlock" if locked else "Lock")
|
||||
GLib.timeout_add(1000, update_labels)
|
||||
|
||||
GLib.timeout_add(1000, update_labels)
|
||||
|
Loading…
Reference in New Issue
Block a user