From db0aa8c0aa95b8db69ce2d292a4a06182df7b89c Mon Sep 17 00:00:00 2001 From: Arif Hasanic Date: Wed, 27 May 2026 13:18:16 +0200 Subject: [PATCH] quick commit --- include/connection/dbus/mpris.hpp | 1 + include/helpers/hypr.hpp | 3 ++- src/connection/dbus/mpris.cpp | 8 +++++--- src/widgets/weather.cpp | 15 +++++++-------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/connection/dbus/mpris.hpp b/include/connection/dbus/mpris.hpp index 1f49921..f51d4e3 100644 --- a/include/connection/dbus/mpris.hpp +++ b/include/connection/dbus/mpris.hpp @@ -17,6 +17,7 @@ class MprisController : public DbusConnection { std::string artwork_url; int64_t length_ms; }; + enum class PlaybackStatus { Playing, Paused, diff --git a/include/helpers/hypr.hpp b/include/helpers/hypr.hpp index 353ab51..a367f20 100644 --- a/include/helpers/hypr.hpp +++ b/include/helpers/hypr.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -127,7 +128,7 @@ class HyprctlHelper { } static void dispatchWorkspace(int workspaceNumber) { - std::string command = "dispatch workspace " + std::to_string(workspaceNumber); + std::string command = "dispatch hl.dsp.focus({ workspace = \"" + std::to_string(workspaceNumber) + "\" })"; sendCommand(command); } }; \ No newline at end of file diff --git a/src/connection/dbus/mpris.cpp b/src/connection/dbus/mpris.cpp index 8cb2d84..6ef3697 100644 --- a/src/connection/dbus/mpris.cpp +++ b/src/connection/dbus/mpris.cpp @@ -107,7 +107,7 @@ void MprisController::on_bus_connected(const Glib::RefPtr &res try { auto list_names_result = m_dbus_proxy->call_sync("ListNames"); auto names_variant = Glib::VariantBase::cast_dynamic< - Glib::Variant>>(list_names_result.get_child(0)); + Glib::Variant>>(list_names_result.get_child(0)); for (const auto &name : names_variant.get()) { const std::string bus_name = name; @@ -349,9 +349,11 @@ void MprisController::on_properties_changed(const Gio::DBus::Proxy::MapChangedPr if (changed_properties.find("PlaybackStatus") != changed_properties.end()) { auto status_var = changed_properties.at("PlaybackStatus"); + if (status_var.is_of_type(Glib::VariantType("s"))) { auto status = Glib::VariantBase::cast_dynamic>(status_var).get(); - spdlog::info("Playback Status changed to: {}", status.raw()); + spdlog::debug("Playback Status changed to: {}", status.raw()); + auto parsedStatusIt = playbackStatusMap.find(static_cast(status)); if (parsedStatusIt != playbackStatusMap.end()) { @@ -367,7 +369,7 @@ void MprisController::on_properties_changed(const Gio::DBus::Proxy::MapChangedPr auto position_var = changed_properties.at("Position"); if (position_var.is_of_type(Glib::VariantType("x"))) { auto position = Glib::VariantBase::cast_dynamic>(position_var).get(); - spdlog::info("Position changed to: {}", position); + spdlog::debug("Position changed to: {}", position); playbackPositionChangedSignal.emit(static_cast(position)); } } diff --git a/src/widgets/weather.cpp b/src/widgets/weather.cpp index 5c89259..ddeb7e7 100644 --- a/src/widgets/weather.cpp +++ b/src/widgets/weather.cpp @@ -47,7 +47,6 @@ WeatherWidget::WeatherWidget() : Gtk::Box(Gtk::Orientation::VERTICAL) { dailyScroll.set_valign(Gtk::Align::START); dailyScroll.set_halign(Gtk::Align::FILL); - this->append(currentScroll); this->append(hourlyScroll); this->append(dailyScroll); @@ -143,11 +142,11 @@ void WeatherWidget::fetchWeather() { dw.apparent_temperature_max = daily["apparent_temperature_max"][i].get(); dw.precipitation_sum = daily["precipitation_sum"][i].get(); dw.weather_code = daily["weather_code"][i].get(); - auto time_str = daily["time"][i].get(); - std::tm tm = {}; + auto time_str = daily["time"][i].get(); + std::tm tm = {}; std::istringstream ss(time_str); ss >> std::get_time(&tm, "%Y-%m-%d"); - + std::mktime(&tm); char buffer[10]; std::strftime(buffer, sizeof(buffer), "%a", &tm); @@ -156,11 +155,11 @@ void WeatherWidget::fetchWeather() { this->daily_weather[i] = dw; } - auto hourly = json["hourly"]; + auto hourly = json["hourly"]; auto current_time = std::time(nullptr); - auto nextHour = std::localtime(¤t_time)->tm_hour + 1; + auto currentHour = std::localtime(¤t_time)->tm_hour; - for (int i = nextHour; i < nextHour + 24; i ++) { + for (int i = currentHour; i < currentHour + 24; i++) { HourlyWeather hw{}; hw.temperature_2m = hourly["temperature_2m"][i].get(); hw.apparent_temperature = hourly["apparent_temperature"][i].get(); @@ -169,7 +168,7 @@ void WeatherWidget::fetchWeather() { hw.precipitation = hourly["precipitation"][i].get(); hw.time = hourly["time"][i].get().substr(11, 5); - this->hourly_weather[i - nextHour] = hw; + this->hourly_weather[i - currentHour] = hw; } } catch (const std::exception &ex) {