diff --git a/include/app.hpp b/include/app.hpp index e51f1a6..69261f8 100644 --- a/include/app.hpp +++ b/include/app.hpp @@ -3,6 +3,7 @@ #include #include "bar/bar.hpp" +#include "connection/dbus/bluetooth.hpp" #include "connection/dbus/notification.hpp" #include "connection/dbus/tray.hpp" #include "services/hyprland.hpp" @@ -29,6 +30,7 @@ class App { std::shared_ptr notificationService = NotificationService::getInstance(); std::shared_ptr notificationController = NotificationController::getInstance(); + std::shared_ptr bluetoothController = BluetoothController::getInstance(); std::shared_ptr mprisController = MprisController::getInstance(); std::shared_ptr hyprlandService = HyprlandService::getInstance(); diff --git a/include/connection/dbus/bluetooth.hpp b/include/connection/dbus/bluetooth.hpp index 0a74bca..824b671 100644 --- a/include/connection/dbus/bluetooth.hpp +++ b/include/connection/dbus/bluetooth.hpp @@ -122,4 +122,7 @@ class BluetoothController : public DbusConnection { // HID Authorization handler void authorizeHIDDevice(const std::string &object_path); + + Glib::RefPtr m_node_info; + std::shared_ptr m_interface_vtable; }; diff --git a/include/connection/dbus/messages.hpp b/include/connection/dbus/messages.hpp index 4c15c33..c036d28 100644 --- a/include/connection/dbus/messages.hpp +++ b/include/connection/dbus/messages.hpp @@ -37,11 +37,11 @@ struct NotifyMessage { std::string body; std::vector actions; NotificationUrgency urgency = NORMAL; - int32_t expire_timeout; + int32_t expire_timeout = -1; // Callback to invoke when an action is triggered std::function on_action; // Guard to prevent multiple action invocations across mirrors - std::shared_ptr actionInvoked; + std::shared_ptr actionInvoked = std::make_shared(false); // image data (if any) from dbus std::optional> imageData; diff --git a/include/services/timerService.hpp b/include/services/timerService.hpp index f1c78e6..b951a57 100644 --- a/include/services/timerService.hpp +++ b/include/services/timerService.hpp @@ -9,6 +9,7 @@ #include "gtkmm/mediafile.h" #include "gtkmm/mediastream.h" #include "sigc++/signal.h" + class TimerService { struct TimerData { uint64_t duration; diff --git a/include/widgets/controlCenter/timer.hpp b/include/widgets/controlCenter/timer.hpp index 216b725..6c6b4f3 100644 --- a/include/widgets/controlCenter/timer.hpp +++ b/include/widgets/controlCenter/timer.hpp @@ -5,7 +5,6 @@ #include #include "components/timer.hpp" -#include "services/timerService.hpp" #include "gtkmm/box.h" diff --git a/resources/bar.css b/resources/bar.css index cacf562..d7a8b7b 100644 --- a/resources/bar.css +++ b/resources/bar.css @@ -171,7 +171,6 @@ tooltip { #spacer { font-weight: 900; padding: 0 5px; - text-shadow: 0 0 5px #ffffffaa; border-radius: 4px; } @@ -181,10 +180,10 @@ tooltip { } .workspace-pill { - padding: 2px 5px; + padding: 2px 4px; border-radius: 4px; - text-shadow: 0 0 2px #646464; margin: 0 2px; + color: #cccccc; transition: background-color 0.2s, color 0.2s, @@ -281,7 +280,7 @@ tooltip { .bluetooth-device-address { font-size: 10px; - color: #cccccc; + color: #cccccce7; } .bluetooth-settings-row { diff --git a/src/connection/dbus/bluetooth.cpp b/src/connection/dbus/bluetooth.cpp index 9b68bcd..ad7818a 100644 --- a/src/connection/dbus/bluetooth.cpp +++ b/src/connection/dbus/bluetooth.cpp @@ -484,28 +484,28 @@ void BluetoothController::registerAgent() { return; try { - auto node_info = Gio::DBus::NodeInfo::create_for_xml(agent_introspection_xml); - auto interface_info = node_info->lookup_interface("org.bluez.Agent1"); + m_node_info = Gio::DBus::NodeInfo::create_for_xml(agent_introspection_xml); + auto interface_info = m_node_info->lookup_interface("org.bluez.Agent1"); - Gio::DBus::InterfaceVTable vtable( + m_interface_vtable = std::make_shared( sigc::mem_fun(*this, &BluetoothController::on_agent_method_call)); - m_agent_id = connection->register_object("/org/bluez/agent", interface_info, vtable); + m_agent_id = connection->register_object("/org/bluez/bar_agent", interface_info, *m_interface_vtable); auto agent_manager = Gio::DBus::Proxy::create_sync( connection, "org.bluez", "/org/bluez", "org.bluez.AgentManager1"); if (agent_manager) { - agent_manager->call( + agent_manager->call_sync( "RegisterAgent", Glib::VariantContainerBase::create_tuple( - {Glib::Variant::create("/org/bluez/agent"), - Glib::Variant::create("KeyboardDisplay")})); // Using KeyboardDisplay capacity + {Glib::Variant::create("/org/bluez/bar_agent"), + Glib::Variant::create("DisplayYesNo")})); - agent_manager->call( + agent_manager->call_sync( "RequestDefaultAgent", Glib::VariantContainerBase::create_tuple( - {Glib::Variant::create("/org/bluez/agent")})); + {Glib::Variant::create("/org/bluez/bar_agent")})); spdlog::info("Bluetooth Agent registered successfully"); } @@ -523,6 +523,8 @@ void BluetoothController::on_agent_method_call( const Glib::VariantContainerBase ¶meters, const Glib::RefPtr &invocation) { + spdlog::info("Bluetooth Agent method called: {}", method_name.c_str()); + if (method_name == "RequestConfirmation") { // Signature: (ou) std::string device_path = static_cast( @@ -547,7 +549,7 @@ void BluetoothController::on_agent_method_call( msg.summary = "Bluetooth Pairing Request"; msg.body = "Device '" + device_name + "' wants to pair.\nPasskey: " + passkey_str; msg.app_name = "Bar"; - msg.actions = {"Confirm", "Cancel"}; + msg.actions = {"Confirm", "Confirm", "Cancel", "Cancel"}; msg.urgency = NotificationUrgency::CRITICAL; msg.expire_timeout = -1; // No timeout, requires user interaction @@ -580,8 +582,8 @@ void BluetoothController::on_agent_method_call( msg.summary = "Bluetooth Authorization Request"; msg.body = "Device '" + device_name + "' requests authorization to connect."; msg.app_name = "Bar"; - msg.actions = {"Allow", "Deny"}; - msg.urgency = NotificationUrgency::CRITICAL; + msg.actions = {"Allow", "Allow", "Deny", "Deny"}; + msg.urgency = NotificationUrgency::LOW; msg.expire_timeout = -1; msg.on_action = [invocation](const std::string &action) { @@ -614,7 +616,7 @@ void BluetoothController::on_agent_method_call( msg.summary = "Bluetooth Service Authorization"; msg.body = "Device '" + device_name + "' wants to access service: " + uuid; msg.app_name = "Bar"; - msg.actions = {"Allow", "Deny"}; + msg.actions = {"Allow", "Allow", "Deny", "Deny"}; msg.urgency = NotificationUrgency::CRITICAL; msg.expire_timeout = -1; @@ -762,4 +764,5 @@ void BluetoothController::on_agent_method_call( // Not implemented invocation->return_dbus_error("org.bluez.Error.Rejected", "Not implemented"); } + } diff --git a/src/widgets/controlCenter/bluetoothSettingsRow.cpp b/src/widgets/controlCenter/bluetoothSettingsRow.cpp index 46da09e..c9af014 100644 --- a/src/widgets/controlCenter/bluetoothSettingsRow.cpp +++ b/src/widgets/controlCenter/bluetoothSettingsRow.cpp @@ -29,9 +29,8 @@ BluetoothSettingsRow::BluetoothSettingsRow(const BluetoothDevice &device) deviceInfoBox.set_spacing(2); append(deviceInfoBox); - std::string shortName = StringHelper::trimToSize(device.name.empty() ? "Unknown Device" : device.name, 14); - - nameLabel.set_text(shortName); + nameLabel.set_ellipsize(Pango::EllipsizeMode::END); + nameLabel.set_text(device.name.empty() ? "Unknown Device" : device.name ); nameLabel.set_halign(Gtk::Align::START); nameLabel.set_valign(Gtk::Align::CENTER); deviceInfoBox.append(nameLabel); @@ -41,6 +40,7 @@ BluetoothSettingsRow::BluetoothSettingsRow(const BluetoothDevice &device) addressLabel.set_valign(Gtk::Align::CENTER); addressLabel.add_css_class("bluetooth-device-address"); deviceInfoBox.append(addressLabel); + deviceInfoBox.set_size_request(140, -1); auto buttonBox = Gtk::Box(Gtk::Orientation::HORIZONTAL); buttonBox.set_hexpand(true); @@ -80,9 +80,7 @@ void BluetoothSettingsRow::updateDevice(const BluetoothDevice &device) { spdlog::info("Updating device {}: paired={}, connected={}, trusted={}", device.name, device.paired, device.connected, device.trusted); - std::string shortName = StringHelper::trimToSize(device.name.empty() ? "Unknown Device" : device.name, 14); - - nameLabel.set_text(shortName); + nameLabel.set_text(device.name.empty() ? "Unknown Device" : device.name); addressLabel.set_text(device.address); pairButton.setIcon(device.paired ? Icon::BLUETOOTH_CONNECTED : Icon::BLUETOOTH); connectButton.setIcon(device.connected ? Icon::LINK : Icon::LINK_OFF); diff --git a/src/widgets/controlCenter/timer.cpp b/src/widgets/controlCenter/timer.cpp index 226e670..8aeedf2 100644 --- a/src/widgets/controlCenter/timer.cpp +++ b/src/widgets/controlCenter/timer.cpp @@ -86,8 +86,12 @@ TimerWidget::TimerWidget() { if (rawDigits.empty()) { return; } - spdlog::info("Timer set for {} seconds", rawDigits); - this->timerService->addTimer(std::stoul(rawDigits)); + + uint64_t rawValue = std::stoull(rawDigits); + uint64_t seconds = (rawValue / 10000) * 3600 + ((rawValue / 100) % 100) * 60 + (rawValue % 100); + + spdlog::info("Timer set for {} seconds", seconds); + this->timerService->addTimer(seconds); rawDigits.clear(); this->updatingText = true; entry->set_text(""); diff --git a/src/widgets/notification/notificationWindow.cpp b/src/widgets/notification/notificationWindow.cpp index 38bcbd1..6917f1b 100644 --- a/src/widgets/notification/notificationWindow.cpp +++ b/src/widgets/notification/notificationWindow.cpp @@ -78,6 +78,7 @@ NotificationWindow::NotificationWindow(uint64_t notificationId, std::shared_ptr< entry->set_hexpand(true); entry->add_css_class("notification-entry"); vbox->append(*entry); + entry->grab_focus_without_selecting(); entry->signal_activate().connect([this, entry, cb = notify.on_input]() { if (cb) {