Skip to content

Commit

Permalink
Fix clipboard in flatpak
Browse files Browse the repository at this point in the history
  • Loading branch information
quexten committed Dec 26, 2023
1 parent 4081d7f commit e675703
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
3 changes: 3 additions & 0 deletions com.quexten.Goldwarden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ modules:
- "--share=network"
build-commands:
- pip3 install --prefix=/app tendo
- git clone https://github.com/bugaevc/wl-clipboard.git
- cd wl-clipboard && meson setup build && cd build && ninja
- install -D wl-clipboard/build/src/wl-copy /app/bin/wl-copy
- 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
Expand Down
6 changes: 5 additions & 1 deletion ui/clipboard.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import subprocess
import os

def write(text):
process = subprocess.Popen(["/bin/sh", "-c", "wl-copy"], stdin=subprocess.PIPE)
# 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'))
12 changes: 4 additions & 8 deletions ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
try:
subprocess.Popen(["python3", "/app/bin/settings.py"], start_new_session=True)
except:
subprocess.Popen(["python3", "./settings.py"], start_new_session=True)
pass

try:
Expand All @@ -32,16 +33,11 @@ def run_daemon():
if not goldwarden.is_daemon_running():
goldwarden.run_daemon()

if not goldwarden.is_daemon_running():
print("daemon not running.. autostarting")
daemonThread = Thread(target=run_daemon)
daemonThread.start()

print("starting autofill monitor")

def on_autofill():
subprocess.Popen(["python3", "/app/bin/autofill.py"], start_new_session=True)
monitors.dbus_autofill_monitor.on_autofill = on_autofill

monitors.dbus_autofill_monitor.on_autofill = lambda: on_autofill()
monitors.dbus_autofill_monitor.run_daemon()

while True:
time.sleep(60)
8 changes: 6 additions & 2 deletions ui/monitors/dbus_autofill_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import dbus.service
from dbus.mainloop.glib import DBusGMainLoop
from threading import Thread
import gi.repository.GLib

on_autofill = lambda: None

Expand All @@ -19,5 +20,8 @@ def autofill(self):
on_autofill()
return ""

DBusGMainLoop(set_as_default=True)
service = GoldwardenDBUSService()
def run_daemon():
mainloop = DBusGMainLoop(set_as_default=True)
service = GoldwardenDBUSService()
mloop = gi.repository.GLib.MainLoop()
mloop.run()

0 comments on commit e675703

Please sign in to comment.