Files
bar/src/app.cpp
2026-02-07 21:16:35 +01:00

60 lines
1.8 KiB
C++

#include "app.hpp"
#include <sigc++/sigc++.h>
#include <vector>
#include "connection/dbus/mpris.hpp"
#include "connection/dbus/notification.hpp"
#include "services/notificationController.hpp"
#include "services/textureCache.hpp"
#include "widgets/wallpaperWindow.hpp"
App::App() {
this->app = Gtk::Application::create("org.example.mybar");
this->setupServices();
this->hyprlandService = HyprlandService::getInstance();
this->notificationService = std::make_shared<NotificationService>();
this->mprisController = MprisController::getInstance();
auto notificationController = NotificationController::getInstance();
this->mprisController->signal_mpris_updated().connect(
[notificationController](const MprisPlayer2Message &msg) {
notificationController->showSpotifyNotification(msg);
});
app->signal_activate().connect([&]() {
auto display = Gdk::Display::get_default();
auto monitors = display->get_monitors();
for (guint i = 0; i < monitors->get_n_items(); ++i) {
auto monitor = std::dynamic_pointer_cast<Gdk::Monitor>(
monitors->get_object(i));
if (monitor) {
auto bar = std::make_shared<Bar>(monitor->gobj());
bar->set_application(app);
bar->show();
std::string monitorName = monitor->get_connector();
bar->addLeftWidget(hyprlandService->getWorkspaceIndicatorsForMonitor(monitorName));
hyprlandService->addBar(bar, monitorName);
bars.push_back(bar);
}
}
});
app->signal_shutdown().connect([&]() {
this->trayService->stop();
});
}
void App::setupServices() {
TextureCacheService::getInstance()->pruneCache();
this->trayService->start();
}
int App::run() { return this->app->run(); }