-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.py
67 lines (49 loc) · 2.09 KB
/
main.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
import setproctitle
from fabric import Application
from fabric.utils import exec_shell_command, get_relative_path, monitor_file
from loguru import logger
import utils.functions as helpers
from modules.bar import StatusBar
from modules.notification_pop_up import NotificationPopup
from modules.osd import OSDContainer
from utils.colors import Colors
from utils.config import widget_config
from utils.constants import APP_CACHE_DIRECTORY, APPLICATION_NAME
from widgets.corners import ScreenCorners
def process_and_apply_css(app: Application):
if not helpers.executable_exists("sass"):
raise helpers.ExecutableNotFoundError(
"sass"
) # Raise an error if sass is not found and exit the application
logger.info(f"{Colors.INFO}[Main] Compiling CSS")
exec_shell_command("sass styles/main.scss dist/main.css --no-source-map")
logger.info(f"{Colors.INFO}[Main] CSS applied")
app.set_stylesheet_from_file(get_relative_path("dist/main.css"))
for log in [
"fabric.hyprland.widgets",
"fabric.audio.service",
"fabric.bluetooth.service",
]:
logger.disable(log)
if __name__ == "__main__":
# Create the status bar
bar = StatusBar()
notifications = NotificationPopup(widget_config)
windows = [notifications, bar]
if widget_config["options"]["screen_corners"]:
windows.append(ScreenCorners())
if widget_config["osd"]["enabled"]:
windows.append(OSDContainer(widget_config))
# Initialize the application with the status bar
app = Application(APPLICATION_NAME, windows=windows)
setproctitle.setproctitle(APPLICATION_NAME)
helpers.ensure_dir_exists(APP_CACHE_DIRECTORY)
helpers.copy_theme(widget_config["theme"]["name"])
# Monitor styles folder for changes
main_css_file = monitor_file(get_relative_path("styles"))
common_css_file = monitor_file(get_relative_path("styles/common"))
main_css_file.connect("changed", lambda *_: process_and_apply_css(app))
common_css_file.connect("changed", lambda *_: process_and_apply_css(app))
process_and_apply_css(app)
# Run the application
app.run()