65 lines
2.1 KiB
Python
65 lines
2.1 KiB
Python
import sys
|
|
import os
|
|
import platform
|
|
import configparser
|
|
from mouseevents import MouseEvents
|
|
from pynput import mouse
|
|
from sightfactory import SightFactory
|
|
from PyQt6.QtWidgets import QApplication
|
|
from pynput.mouse import Controller
|
|
import subprocess
|
|
|
|
def init():
|
|
global data, sights, mousectrl, app
|
|
#init the basic values
|
|
app = QApplication(sys.argv)
|
|
mousectrl = Controller()
|
|
sights = SightFactory()
|
|
data = {}
|
|
data["move"] = False
|
|
data["active_sight"] = "main"
|
|
data["platform"] = {}
|
|
data["platform"]["system"] = platform.system()
|
|
data["sight_processes"] = {}
|
|
data["mouse_distance_x"] = 0
|
|
data["mouse_distance_y"] = 0
|
|
data["display_server"] = ""
|
|
if data["platform"]["system"] == "Linux":
|
|
args = ["echo -n $XDG_SESSION_TYPE"]
|
|
result = subprocess.check_output(args, shell=True)
|
|
data["display_server"] = result.decode('ascii')
|
|
print("D "+data["display_server"])
|
|
data["base_dir"]=os.path.abspath(os.getcwd())+os.path.sep
|
|
data["template_dir"]=data["base_dir"]+"place"+os.path.sep+"templates"+os.path.sep
|
|
#LOAD the template config content
|
|
loadConfigTemplate()
|
|
#Events
|
|
mouseevent = MouseEvents()
|
|
start()
|
|
|
|
def frameSupported():
|
|
if data["display_server"] == "wayland":
|
|
return False
|
|
return True
|
|
|
|
def loadConfigTemplate():
|
|
config = configparser.ConfigParser()
|
|
config.sections()
|
|
config.read(data["template_dir"]+"config.ini")
|
|
if "DEFAULT" in config:
|
|
data["default_template"] = config["DEFAULT"]["default_template"]
|
|
data["default_template_page"] = config["DEFAULT"]["default_template_page"]
|
|
data["default_template_dir"] = data["template_dir"]+data["default_template"]+os.path.sep
|
|
data["sight_mode"] = config["DEFAULT"]["sight_mode"]
|
|
print("Template config is loaded!")
|
|
else:
|
|
print("Missing 'DEFAULT' data from the templates config.ini folder. It can't start!")
|
|
|
|
def start():
|
|
# Creating the main Sight
|
|
sights.create("main", data["default_template_page"]);
|
|
sights.processes();
|
|
sights.show("main");
|
|
|
|
app.exec()
|