quick commit

This commit is contained in:
2026-05-27 13:18:16 +02:00
parent 0549437776
commit db0aa8c0aa
4 changed files with 15 additions and 12 deletions
+1
View File
@@ -17,6 +17,7 @@ class MprisController : public DbusConnection {
std::string artwork_url; std::string artwork_url;
int64_t length_ms; int64_t length_ms;
}; };
enum class PlaybackStatus { enum class PlaybackStatus {
Playing, Playing,
Paused, Paused,
+2 -1
View File
@@ -6,6 +6,7 @@
#include <cstring> #include <cstring>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <span> #include <span>
#include <spdlog/spdlog.h>
#include <string> #include <string>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/un.h> #include <sys/un.h>
@@ -127,7 +128,7 @@ class HyprctlHelper {
} }
static void dispatchWorkspace(int workspaceNumber) { 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); sendCommand(command);
} }
}; };
+5 -3
View File
@@ -107,7 +107,7 @@ void MprisController::on_bus_connected(const Glib::RefPtr<Gio::AsyncResult> &res
try { try {
auto list_names_result = m_dbus_proxy->call_sync("ListNames"); auto list_names_result = m_dbus_proxy->call_sync("ListNames");
auto names_variant = Glib::VariantBase::cast_dynamic< auto names_variant = Glib::VariantBase::cast_dynamic<
Glib::Variant<std::vector<Glib::ustring>>>(list_names_result.get_child(0)); Glib::Variant<std::vector<Glib::ustring>>>(list_names_result.get_child(0));
for (const auto &name : names_variant.get()) { for (const auto &name : names_variant.get()) {
const std::string bus_name = name; 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()) { if (changed_properties.find("PlaybackStatus") != changed_properties.end()) {
auto status_var = changed_properties.at("PlaybackStatus"); auto status_var = changed_properties.at("PlaybackStatus");
if (status_var.is_of_type(Glib::VariantType("s"))) { if (status_var.is_of_type(Glib::VariantType("s"))) {
auto status = Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::ustring>>(status_var).get(); auto status = Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::ustring>>(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<std::string>(status)); auto parsedStatusIt = playbackStatusMap.find(static_cast<std::string>(status));
if (parsedStatusIt != playbackStatusMap.end()) { 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"); auto position_var = changed_properties.at("Position");
if (position_var.is_of_type(Glib::VariantType("x"))) { if (position_var.is_of_type(Glib::VariantType("x"))) {
auto position = Glib::VariantBase::cast_dynamic<Glib::Variant<gint64>>(position_var).get(); auto position = Glib::VariantBase::cast_dynamic<Glib::Variant<gint64>>(position_var).get();
spdlog::info("Position changed to: {}", position); spdlog::debug("Position changed to: {}", position);
playbackPositionChangedSignal.emit(static_cast<int64_t>(position)); playbackPositionChangedSignal.emit(static_cast<int64_t>(position));
} }
} }
+6 -7
View File
@@ -47,7 +47,6 @@ WeatherWidget::WeatherWidget() : Gtk::Box(Gtk::Orientation::VERTICAL) {
dailyScroll.set_valign(Gtk::Align::START); dailyScroll.set_valign(Gtk::Align::START);
dailyScroll.set_halign(Gtk::Align::FILL); dailyScroll.set_halign(Gtk::Align::FILL);
this->append(currentScroll); this->append(currentScroll);
this->append(hourlyScroll); this->append(hourlyScroll);
this->append(dailyScroll); this->append(dailyScroll);
@@ -143,8 +142,8 @@ void WeatherWidget::fetchWeather() {
dw.apparent_temperature_max = daily["apparent_temperature_max"][i].get<double>(); dw.apparent_temperature_max = daily["apparent_temperature_max"][i].get<double>();
dw.precipitation_sum = daily["precipitation_sum"][i].get<double>(); dw.precipitation_sum = daily["precipitation_sum"][i].get<double>();
dw.weather_code = daily["weather_code"][i].get<int>(); dw.weather_code = daily["weather_code"][i].get<int>();
auto time_str = daily["time"][i].get<std::string>(); auto time_str = daily["time"][i].get<std::string>();
std::tm tm = {}; std::tm tm = {};
std::istringstream ss(time_str); std::istringstream ss(time_str);
ss >> std::get_time(&tm, "%Y-%m-%d"); ss >> std::get_time(&tm, "%Y-%m-%d");
@@ -156,11 +155,11 @@ void WeatherWidget::fetchWeather() {
this->daily_weather[i] = dw; this->daily_weather[i] = dw;
} }
auto hourly = json["hourly"]; auto hourly = json["hourly"];
auto current_time = std::time(nullptr); auto current_time = std::time(nullptr);
auto nextHour = std::localtime(&current_time)->tm_hour + 1; auto currentHour = std::localtime(&current_time)->tm_hour;
for (int i = nextHour; i < nextHour + 24; i ++) { for (int i = currentHour; i < currentHour + 24; i++) {
HourlyWeather hw{}; HourlyWeather hw{};
hw.temperature_2m = hourly["temperature_2m"][i].get<double>(); hw.temperature_2m = hourly["temperature_2m"][i].get<double>();
hw.apparent_temperature = hourly["apparent_temperature"][i].get<double>(); hw.apparent_temperature = hourly["apparent_temperature"][i].get<double>();
@@ -169,7 +168,7 @@ void WeatherWidget::fetchWeather() {
hw.precipitation = hourly["precipitation"][i].get<double>(); hw.precipitation = hourly["precipitation"][i].get<double>();
hw.time = hourly["time"][i].get<std::string>().substr(11, 5); hw.time = hourly["time"][i].get<std::string>().substr(11, 5);
this->hourly_weather[i - nextHour] = hw; this->hourly_weather[i - currentHour] = hw;
} }
} catch (const std::exception &ex) { } catch (const std::exception &ex) {