mirror of
https://github.com/rangermix/TwitchDropsMiner.git
synced 2026-05-26 23:19:39 +00:00
Support autostart when running from source
This commit is contained in:
@@ -33,6 +33,11 @@ else:
|
||||
# The Lib folder is also spelled in lowercase: 'lib'
|
||||
version_info = sys.version_info
|
||||
SYS_SITE_PACKAGES = f"lib/python{version_info.major}.{version_info.minor}/site-packages"
|
||||
# scripts venv path changes depending on the system platform
|
||||
if sys.platform == "win32":
|
||||
SYS_SCRIPTS = "Scripts"
|
||||
else:
|
||||
SYS_SCRIPTS = "bin"
|
||||
|
||||
|
||||
def _resource_path(relative_path: Path | str) -> Path:
|
||||
@@ -90,6 +95,7 @@ WORKING_DIR = SELF_PATH.parent
|
||||
# Development paths
|
||||
VENV_PATH = Path(WORKING_DIR, "env")
|
||||
SITE_PACKAGES_PATH = Path(VENV_PATH, SYS_SITE_PACKAGES)
|
||||
SCRIPTS_PATH = Path(VENV_PATH, SYS_SCRIPTS)
|
||||
# Translations path
|
||||
# NOTE: These don't have to be available to the end-user, so the path points to the internal dir
|
||||
LANG_PATH = _resource_path("lang")
|
||||
|
||||
12
gui.py
12
gui.py
@@ -34,6 +34,8 @@ from exceptions import MinerException, ExitRequest
|
||||
from utils import resource_path, set_root_icon, webopen, Game, _T
|
||||
from constants import (
|
||||
SELF_PATH,
|
||||
IS_PACKAGED,
|
||||
SCRIPTS_PATH,
|
||||
WINDOW_TITLE,
|
||||
LOGGING_LEVELS,
|
||||
MAX_WEBSOCKETS,
|
||||
@@ -1742,7 +1744,7 @@ class SettingsPanel:
|
||||
return f'"{SELF_PATH.resolve()!s}"'
|
||||
|
||||
def _get_autostart_path(self) -> str:
|
||||
flags: list[str] = [''] # this will add a space between self path and flags
|
||||
flags: list[str] = []
|
||||
# if applicable, include the current logging level as well
|
||||
for lvl_idx, lvl_value in LOGGING_LEVELS.items():
|
||||
if lvl_value == self._settings.logging_level:
|
||||
@@ -1751,7 +1753,10 @@ class SettingsPanel:
|
||||
break
|
||||
if self._vars["tray"].get():
|
||||
flags.append("--tray")
|
||||
return self._get_self_path() + ' '.join(flags)
|
||||
if not IS_PACKAGED:
|
||||
# non-packaged autostart has to be done through the venv path pythonw
|
||||
return f"\"{SCRIPTS_PATH / 'pythonw'!s}\" {self._get_self_path()} {' '.join(flags)}"
|
||||
return f"{self._get_self_path()} {' '.join(flags)}"
|
||||
|
||||
def _get_linux_autostart_filepath(self) -> Path:
|
||||
autostart_folder: Path = Path("~/.config/autostart").expanduser()
|
||||
@@ -2407,11 +2412,12 @@ if __name__ == "__main__":
|
||||
tray=False,
|
||||
priority=[],
|
||||
proxy=URL(),
|
||||
alter=lambda: None,
|
||||
language="English",
|
||||
autostart_tray=False,
|
||||
exclude={"Lit Game"},
|
||||
tray_notifications=True,
|
||||
alter=lambda: None,
|
||||
logging_level=LOGGING_LEVELS[0],
|
||||
priority_mode=PriorityMode.PRIORITY_ONLY,
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user