From 6ee67d6569c746d92c08c2357ac4790399c435a9 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Sat, 17 Feb 2024 13:32:58 +0100 Subject: [PATCH] Use gtk clipboard instead of wl clipboard --- com.quexten.Goldwarden.yml | 8 -------- gui/src/gui/quickaccess.py | 29 ++++++++++++++--------------- gui/src/linux/clipboard.py | 9 --------- 3 files changed, 14 insertions(+), 32 deletions(-) delete mode 100644 gui/src/linux/clipboard.py diff --git a/com.quexten.Goldwarden.yml b/com.quexten.Goldwarden.yml index ff413c6..e0b46a7 100644 --- a/com.quexten.Goldwarden.yml +++ b/com.quexten.Goldwarden.yml @@ -29,14 +29,6 @@ finish-args: - --system-talk-name=org.freedesktop.PolicyKit1 modules: - ./gui/python3-requirements.json - - name: wl-clipboard - buildsystem: meson - config-opts: - - -Dfishcompletiondir=no - sources: - - type: git - url: https://github.com/bugaevc/wl-clipboard.git - tag: v2.2.1 - name: goldwarden-python-ui buildsystem: simple build-commands: diff --git a/gui/src/gui/quickaccess.py b/gui/src/gui/quickaccess.py index f7b7825..f7934b0 100644 --- a/gui/src/gui/quickaccess.py +++ b/gui/src/gui/quickaccess.py @@ -6,34 +6,33 @@ import gc import time from gi.repository import Gtk, Adw, GLib, Notify, Gdk from ..services import goldwarden -from ..linux import clipboard from threading import Thread import sys import os from ..services import totp Notify.init("Goldwarden") -token = sys.stdin.readline() +token = "Test" goldwarden.create_authenticated_connection(token) def autotype(text): - time.sleep(0.5) + time.sleep(2) + print("Autotyping") goldwarden.autotype(text) + print("Autotyped") + time.sleep(5) os._exit(0) def set_clipboard(text): - print("Setting clipboard") - try: - clipboard.write(text) - except Exception as e: - print(e) - pass - display = Gdk.Display.get_default() - clipboard = Gdk.Display.get_clipboard(display) - clipboard.set(text) - print("Clipboard set", text) - time.sleep(0.5) - os._exit(0) + Gdk.Display.get_clipboard(Gdk.Display.get_default()).set_content( + Gdk.ContentProvider.new_for_value(text) + ) + + def kill(): + time.sleep(0.5) + os._exit(0) + thread = Thread(target=kill) + thread.start() class MyApp(Adw.Application): def __init__(self, **kwargs): diff --git a/gui/src/linux/clipboard.py b/gui/src/linux/clipboard.py deleted file mode 100644 index f193f80..0000000 --- a/gui/src/linux/clipboard.py +++ /dev/null @@ -1,9 +0,0 @@ -import subprocess -import os - -def write(text): - # set path - env = os.environ.copy() - env["PATH"] = env["PATH"] + ":/app/bin" - process = subprocess.Popen(["/bin/sh", "-c", "wl-copy"], stdin=subprocess.PIPE, env=env) - process.communicate(text.encode('utf-8')) \ No newline at end of file