From e71dd9199e1e77665e8f076fce5b8b6194063b98 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Tue, 26 Dec 2023 21:31:03 +0100 Subject: [PATCH] Add autotype instructions and button --- Readme.md | 16 +++++++++++++--- ui/settings.py | 13 ++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index bbb7b4a..33834ee 100644 --- a/Readme.md +++ b/Readme.md @@ -91,11 +91,21 @@ Run a command with injected environment variables goldwarden run -- ``` -Autofill (Flatpak Only) +#### Autofill (Flatpak Only) + +To set up a shortcut (CTRL+u) on Gnome: ``` -dbus-send --type=method_call --dest=com.quexten.goldwarden /com/quexten/goldwarden com.quexten.goldwarden.Autofill.autofill +gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/gwautofill/']" +gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/gwautofill/ name 'Goldwarden Autofill' +gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/gwautofill/ command 'dbus-send --type=method_call --dest=com.quexten.Goldwarden.autofill /com/quexten/Goldwarden com.quexten.Goldwarden.Autofill.autofill' +gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/gwautofill/ binding 'u' ``` -(Create a hotkey for this depending on your desktop environment) + +On other Desktop environments this will work differently, just makes sure that: +`dbus-send --type=method_call --dest=com.quexten.Goldwarden.autofill /com/quexten/Goldwarden com.quexten.Goldwarden.Autofill.autofill` +gets called. + +This will be changed once desktop environments implement the global hotkey portal. #### SSH Agent [goldwarden_ssh.webm](https://github.com/quexten/goldwarden/assets/11866552/9058f734-60e0-4dd3-b9f8-1d77f7cf4c65) diff --git a/ui/settings.py b/ui/settings.py index 98d3f44..caa9ab8 100644 --- a/ui/settings.py +++ b/ui/settings.py @@ -8,14 +8,12 @@ import gc from gi.repository import Gtk, Adw, GLib import goldwarden from threading import Thread - -hidden = False +import subprocess class SettingsWinvdow(Gtk.ApplicationWindow): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - print("init settings window") self.stack = Gtk.Stack() self.stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT) self.set_child(self.stack) @@ -85,6 +83,13 @@ class SettingsWinvdow(Gtk.ApplicationWindow): self.action_preferences_group.set_title("Actions") self.preferences_page.add(self.action_preferences_group) + self.autotype_button = Gtk.Button() + self.autotype_button.set_label("Autotype") + self.autotype_button.set_margin_top(10) + self.autotype_button.connect("clicked", lambda button: subprocess.Popen(["python3", "/app/bin/autofill.py"], start_new_session=True)) + self.autotype_button.get_style_context().add_class("suggested-action") + self.action_preferences_group.add(self.autotype_button) + self.login_button = Gtk.Button() self.login_button.set_label("Login") self.login_button.connect("clicked", lambda button: show_login()) @@ -130,6 +135,7 @@ class SettingsWinvdow(Gtk.ApplicationWindow): 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.autotype_button.set_sensitive(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"])) @@ -159,6 +165,7 @@ class MyApp(Adw.Application): self.settings_win = SettingsWinvdow(application=app) self.settings_win.present() +app = MyApp(application_id="com.quexten.Goldwarden") def show_login(): dialog = Gtk.Dialog(title="Goldwarden")