forked from StreamController/StreamController
-
Notifications
You must be signed in to change notification settings - Fork 0
/
globals.py
119 lines (105 loc) · 5.25 KB
/
globals.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import json
import Pyro5.api
import os
from typing import TYPE_CHECKING
import argparse
import sys
from loguru import logger as log
from src.backend.DeckManagement.HelperMethods import find_fallback_font
argparser = argparse.ArgumentParser()
argparser.add_argument("-b", help="Open in background", action="store_true")
argparser.add_argument("--devel", help="Developer mode (disables auto update)", action="store_true")
argparser.add_argument("--skip-load-hardware-decks", help="Skips initilization/use of hardware decks", action="store_true")
argparser.add_argument("--close-running", help="Close running", action="store_true")
argparser.add_argument("--data", help="Data path", type=str)
argparser.add_argument("--change-page", action="append", nargs=2, help="Change the page for a device", metavar=("SERIAL_NUMBER", "PAGE_NAME"))
argparser.add_argument("app_args", nargs="*")
VAR_APP_PATH = os.path.join(os.path.expanduser("~"), ".var", "app", "com.core447.StreamController")
STATIC_SETTINGS_FILE_PATH = os.path.join(VAR_APP_PATH, "static", "settings.json")
DATA_PATH = os.path.join(VAR_APP_PATH, "data") # Maybe use XDG_DATA_HOME instead
if argparser.parse_args().data:
DATA_PATH = argparser.parse_args().data
elif not argparser.parse_args().devel:
# Check static settings
if os.path.exists(STATIC_SETTINGS_FILE_PATH):
try:
with open(STATIC_SETTINGS_FILE_PATH) as f:
settings = json.load(f)
if "data-path" in settings:
DATA_PATH = settings["data-path"]
print()
log.info(f"Using data path from static settings: {DATA_PATH}")
except Exception as e:
log.error(f"Failed to set data path from static settings: {e}")
if not os.path.exists(DATA_PATH):
os.makedirs(DATA_PATH)
PLUGIN_DIR = os.path.join(DATA_PATH, "plugins")
# Used for nix packaging
if os.getenv("PLUGIN_DIR") is not None:
PLUGIN_DIR = os.getenv("PLUGIN_DIR")
top_level_folder = os.path.dirname(PLUGIN_DIR)
sys.path.append(top_level_folder)
if os.path.exists(os.path.join(DATA_PATH, "plugins")):
log.warning(f"You're using a plugin dir path outside of your data dir, but also have a plugin dir in the data dir. This may cause problems.")
os.makedirs(PLUGIN_DIR, exist_ok=True)
# Add data path to sys.path
sys.path.append(DATA_PATH)
if TYPE_CHECKING:
from src.app import App
from locales.LocaleManager import LocaleManager
from src.backend.AssetManagerBackend import AssetManagerBackend
from src.windows.AssetManager.AssetManager import AssetManager
from src.backend.MediaManager import MediaManager
from src.backend.PageManagement.PageManagerBackend import PageManagerBackend
from src.backend.SettingsManager import SettingsManager
from src.backend.DeckManagement.DeckManager import DeckManager
from src.backend.PluginManager.PluginManager import PluginManager
from src.backend.IconPackManagement.IconPackManager import IconPackManager
from src.backend.WallpaperPackManagement.WallpaperPackManager import WallpaperPackManager
from src.backend.Store.StoreBackend import StoreBackend
from src.Signals.SignalManager import SignalManager
from src.backend.WindowGrabber.WindowGrabber import WindowGrabber
from src.backend.GnomeExtensions import GnomeExtensions
from src.windows.Store.Store import Store
from src.backend.PermissionManagement.FlatpakPermissionManager import FlatpakPermissionManager
from src.windows.PageManager.PageManager import PageManager
from src.backend.LockScreenManager.LockScreenManager import LockScreenManager
from src.tray import TrayIcon
top_level_dir:str = os.path.dirname(__file__)
lm:"LocaleManager" = None
media_manager:"MediaManager" = None #MediaManager
asset_manager_backend:"AssetManagerBackend" = None #AssetManager
asset_manager: "AssetManager" = None
page_manager_window: "PageManager" = None # Only if opened
page_manager:"PageManagerBackend" = None #PageManager #TODO: Rename to page_manager_backend in 2.0.0
gnome_extensions:"GnomeExtensions" = None
settings_manager:"SettingsManager" = None #SettingsManager
app:"App" = None #App
deck_manager:"DeckManager" = None #DeckManager
plugin_manager:"PluginManager" = None #PluginManager
video_extensions = ["mp4", "mov", "MP4", "MOV", "mkv", "MKV", "webm", "WEBM", "gif", "GIF"]
image_extensions = ["png", "jpg", "jpeg"]
svg_extensions = ["svg", "SVG"]
icon_pack_manager: "IconPackManager" = None
wallpaper_pack_manager: "WallpaperPackManager" = None
store_backend: "StoreBackend" = None
pyro_daemon: Pyro5.api.Daemon = None
signal_manager: "SignalManager" = None
window_grabber: "WindowGrabber" = None
lock_screen_detector: "LockScreenDetector" = None
store: "Store" = None # Only if opened
flatpak_permission_manager: "FlatpakPermissionManager" = None
threads_running: bool = True
app_loading_finished_tasks: callable = []
api_page_requests: dict[str, str] = {} # Stores api page requests made my --change-page
tray_icon: "TrayIcon" = None
fallback_font: str = find_fallback_font()
app_version: str = "1.5.0-beta.6" # In breaking.feature.fix-state format
exact_app_version_check: bool = False
logs: list[str] = []
release_notes: str = """
<ul>
<li>Fix: Ignoring choosen brightness for screensaver</li>
<li>Fix: Actions cannot change background color</li>
</ul>
"""