2023-12-23 07:18:30 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
import time
|
2023-12-23 12:26:01 +01:00
|
|
|
import subprocess
|
|
|
|
from tendo import singleton
|
|
|
|
import monitors.dbus_autofill_monitor
|
|
|
|
import sys
|
2023-12-23 13:24:46 +01:00
|
|
|
import goldwarden
|
|
|
|
from threading import Thread
|
2023-12-28 01:09:49 +01:00
|
|
|
import os
|
|
|
|
|
|
|
|
isflatpak = os.path.exists("/.flatpak-info")
|
|
|
|
pathprefix = "/app/bin/" if isflatpak else "./"
|
2023-12-23 07:18:30 +01:00
|
|
|
|
2023-12-23 12:26:01 +01:00
|
|
|
try:
|
2023-12-28 01:09:49 +01:00
|
|
|
subprocess.Popen(["python3", f'{pathprefix}background.py'], start_new_session=True)
|
2023-12-23 12:26:01 +01:00
|
|
|
except:
|
|
|
|
pass
|
2023-12-23 07:18:30 +01:00
|
|
|
|
2023-12-23 13:44:41 +01:00
|
|
|
is_hidden = "--hidden" in sys.argv
|
|
|
|
|
|
|
|
if not is_hidden:
|
2023-12-23 12:26:01 +01:00
|
|
|
try:
|
2023-12-28 01:09:49 +01:00
|
|
|
subprocess.Popen(["python3", f'{pathprefix}settings.py'], start_new_session=True)
|
2023-12-23 12:26:01 +01:00
|
|
|
except:
|
2023-12-28 01:09:49 +01:00
|
|
|
subprocess.Popen(["python3", f'{pathprefix}settings.py'], start_new_session=True)
|
2023-12-23 12:26:01 +01:00
|
|
|
pass
|
2023-12-23 07:18:30 +01:00
|
|
|
|
2023-12-23 12:26:01 +01:00
|
|
|
try:
|
|
|
|
me = singleton.SingleInstance()
|
|
|
|
except:
|
|
|
|
exit()
|
2023-12-23 07:18:30 +01:00
|
|
|
|
2023-12-23 13:24:46 +01:00
|
|
|
def run_daemon():
|
|
|
|
# todo: do a proper check
|
2023-12-23 13:44:41 +01:00
|
|
|
if is_hidden:
|
|
|
|
time.sleep(20)
|
2023-12-26 20:49:47 +01:00
|
|
|
print("IS daemon running", goldwarden.is_daemon_running())
|
2023-12-23 13:24:46 +01:00
|
|
|
if not goldwarden.is_daemon_running():
|
2023-12-26 20:49:47 +01:00
|
|
|
print("running daemon")
|
2023-12-23 13:24:46 +01:00
|
|
|
goldwarden.run_daemon()
|
2023-12-26 20:49:47 +01:00
|
|
|
print("daemon running")
|
|
|
|
|
|
|
|
thread = Thread(target=run_daemon)
|
|
|
|
thread.start()
|
2023-12-23 13:24:46 +01:00
|
|
|
|
2023-12-23 07:18:30 +01:00
|
|
|
def on_autofill():
|
2023-12-28 01:09:49 +01:00
|
|
|
subprocess.Popen(["python3", f'{pathprefix}autofill.py'], start_new_session=True)
|
2023-12-26 16:32:11 +01:00
|
|
|
|
|
|
|
monitors.dbus_autofill_monitor.on_autofill = lambda: on_autofill()
|
|
|
|
monitors.dbus_autofill_monitor.run_daemon()
|
2023-12-23 07:18:30 +01:00
|
|
|
|
2023-12-23 12:26:01 +01:00
|
|
|
while True:
|
|
|
|
time.sleep(60)
|