feat: sims notifications
This commit is contained in:
44
sims/main.py
44
sims/main.py
@@ -25,11 +25,16 @@ from .modules.launcher.clipboard import ClipboardMenu
|
||||
from .modules.launcher.power import PowerMenu
|
||||
from .modules.launcher.screenrec import ScreenrecMenu
|
||||
from .modules.launcher.screenshot import ScreenshotMenu
|
||||
from .modules.notification_center import NotificationCenter
|
||||
from .modules.notifications import NotificationToasts
|
||||
from .modules.stylix import get_stylix_css_path
|
||||
from .config import POWER, SCREENREC, STYLIX
|
||||
from .config import NOTIFICATIONS, POWER, SCREENREC, STYLIX
|
||||
from .services.fenster import get_i3_connection
|
||||
from .services.notification_history import NotificationHistoryService
|
||||
from .services.screenrec import ScreenrecService
|
||||
|
||||
from fabric.notifications import Notifications
|
||||
|
||||
|
||||
tray = SystemTray(name="system-tray", spacing=4)
|
||||
get_i3_connection()
|
||||
@@ -49,12 +54,41 @@ if SCREENREC.get("enable", False):
|
||||
)
|
||||
screenrec_menu = ScreenrecMenu(screenrec_service)
|
||||
|
||||
notifications_service: Notifications | None = None
|
||||
notification_history: NotificationHistoryService | None = None
|
||||
notification_toasts: NotificationToasts | None = None
|
||||
notification_center: NotificationCenter | None = None
|
||||
if NOTIFICATIONS.get("enable", False):
|
||||
notifications_service = Notifications()
|
||||
notification_history = NotificationHistoryService(
|
||||
notifications_service,
|
||||
history_size=NOTIFICATIONS.get("history_size", 50),
|
||||
image_max_px=NOTIFICATIONS.get("image_max_px", 128),
|
||||
)
|
||||
notification_toasts = NotificationToasts(
|
||||
notifications_service,
|
||||
monitor=0,
|
||||
anchor=NOTIFICATIONS.get("anchor", "top center"),
|
||||
margin=NOTIFICATIONS.get("margin", "8px"),
|
||||
width=NOTIFICATIONS.get("width", 360),
|
||||
timeout_ms=NOTIFICATIONS.get("timeout_ms", 10_000),
|
||||
)
|
||||
notification_center = NotificationCenter(
|
||||
notification_history,
|
||||
monitor=0,
|
||||
width=NOTIFICATIONS.get("center_width", 380),
|
||||
)
|
||||
|
||||
bar_windows = []
|
||||
notmuch_widget = None
|
||||
|
||||
_app_windows = [dummy, finder, app_launcher, clipboard_menu, power_menu, screenshot_menu]
|
||||
if screenrec_menu is not None:
|
||||
_app_windows.append(screenrec_menu)
|
||||
if notification_toasts is not None:
|
||||
_app_windows.append(notification_toasts)
|
||||
if notification_center is not None:
|
||||
_app_windows.append(notification_center)
|
||||
app = Application("sims", *_app_windows)
|
||||
|
||||
|
||||
@@ -113,6 +147,12 @@ def screenrec_stop():
|
||||
screenrec_service.stop()
|
||||
|
||||
|
||||
@Application.action()
|
||||
def toggle_notification_center():
|
||||
if notification_center is not None:
|
||||
notification_center.toggle()
|
||||
|
||||
|
||||
def _set_all_bars_rounded(rounded: bool):
|
||||
for bar in bar_windows:
|
||||
bar.set_corners_rounded(rounded)
|
||||
@@ -170,6 +210,8 @@ def spawn_bars():
|
||||
tray=tray if i == 0 else None,
|
||||
monitor=i,
|
||||
screenrec_service=screenrec_service if i == 0 else None,
|
||||
notification_history=notification_history if i == 0 else None,
|
||||
notification_center=notification_center if i == 0 else None,
|
||||
)
|
||||
bar_windows.append(bar)
|
||||
if i == 0 and bar.notmuch:
|
||||
|
||||
Reference in New Issue
Block a user