forked from Axenide/Ax-Shell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
160 lines (129 loc) · 5.45 KB
/
main.py
File metadata and controls
160 lines (129 loc) · 5.45 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import os
import sys
import gi
gi.require_version("GLib", "2.0")
import setproctitle
from fabric import Application
from fabric.utils import exec_shell_command_async, get_relative_path
from gi.repository import GLib
from config.data import APP_NAME, CACHE_DIR, CONFIG_FILE
from modules.bar import Bar
from modules.corners import Corners
from modules.dock import Dock
from modules.notch import Notch
from modules.notifications import NotificationPopup
import subprocess as _sp
fonts_updated_file = f"{CACHE_DIR}/fonts_updated"
if __name__ == "__main__":
setproctitle.setproctitle(APP_NAME)
if not os.path.isfile(CONFIG_FILE):
config_script_path = get_relative_path("config/config.py")
exec_shell_command_async(f"python {config_script_path}")
current_wallpaper = os.path.expanduser("~/.current.wall")
if not os.path.exists(current_wallpaper):
example_wallpaper = os.path.expanduser(
f"~/.config/{APP_NAME}/assets/wallpapers_example/example-1.jpg"
)
os.symlink(example_wallpaper, current_wallpaper)
# Load configuration
from config.data import load_config
config = load_config()
def _launch_updater(force=False):
"""Launch the PySide6 updater in a separate process."""
cmd = [sys.executable, "-m", "modules.updater"]
if force:
cmd.append("--force")
try:
_sp.Popen(cmd, cwd=os.path.dirname(os.path.abspath(__file__)))
except Exception as e:
print(f"Error launching updater: {e}")
GLib.idle_add(_launch_updater)
GLib.timeout_add(3600000, _launch_updater)
# Initialize multi-monitor services
try:
from utils.monitor_manager import get_monitor_manager
from services.monitor_focus import get_monitor_focus_service
from utils.global_keybinds import init_global_keybind_objects
monitor_manager = get_monitor_manager()
monitor_focus_service = get_monitor_focus_service()
monitor_manager.set_monitor_focus_service(monitor_focus_service)
init_global_keybind_objects()
# Get all available monitors
all_monitors = monitor_manager.get_monitors()
multi_monitor_enabled = True
except ImportError:
# Fallback to single monitor mode
all_monitors = [{'id': 0, 'name': 'default'}]
monitor_manager = None
multi_monitor_enabled = False
# Filter monitors based on selected_monitors configuration
selected_monitors_config = config.get("selected_monitors", [])
# If selected_monitors is empty, show on all monitors (current behavior)
if not selected_monitors_config:
monitors = all_monitors
print("Aw-Shell: No specific monitors selected, showing on all monitors")
else:
# Filter monitors to only include selected ones
monitors = []
selected_monitor_names = set(selected_monitors_config)
for monitor in all_monitors:
monitor_name = monitor.get('name', f'monitor-{monitor.get("id", 0)}')
if monitor_name in selected_monitor_names:
monitors.append(monitor)
print(f"Aw-Shell: Including monitor '{monitor_name}' (selected)")
else:
print(f"Aw-Shell: Excluding monitor '{monitor_name}' (not selected)")
# Fallback: if no valid monitors found, use all monitors
if not monitors:
print("Aw-Shell: No valid selected monitors found, falling back to all monitors")
monitors = all_monitors
# Create application components list
app_components = []
corners = None
notification = None
# Create components for each monitor
for monitor in monitors:
monitor_id = monitor['id']
# Create corners only for the first monitor (shared across all)
if monitor_id == 0:
corners = Corners()
# Set corners visibility based on config
corners_visible = config.get("corners_visible", True)
corners.set_visible(corners_visible)
app_components.append(corners)
# Create monitor-specific components
if multi_monitor_enabled:
bar = Bar(monitor_id=monitor_id)
notch = Notch(monitor_id=monitor_id)
dock = Dock(monitor_id=monitor_id)
else:
# Single monitor fallback
bar = Bar()
notch = Notch()
dock = Dock()
# Connect bar and notch
bar.notch = notch
notch.bar = bar
# Create notification popup for the first monitor only
if monitor_id == 0:
notification = NotificationPopup(widgets=notch.dashboard.widgets)
app_components.append(notification)
# Register instances in monitor manager if available
if multi_monitor_enabled and monitor_manager:
monitor_manager.register_monitor_instances(monitor_id, {
'bar': bar,
'notch': notch,
'dock': dock,
'corners': corners if monitor_id == 0 else None
})
# Add components to app list
app_components.extend([bar, notch, dock])
# Create the application with all components
app = Application(f"{APP_NAME}", *app_components)
def set_css():
app.set_stylesheet_from_file(
get_relative_path("main.css"),
)
app.set_css = set_css
app.set_css()
app.run()