quick commit
This commit is contained in:
@@ -17,6 +17,7 @@ class MprisController : public DbusConnection {
|
||||
std::string artwork_url;
|
||||
int64_t length_ms;
|
||||
};
|
||||
|
||||
enum class PlaybackStatus {
|
||||
Playing,
|
||||
Paused,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <cstring>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <span>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <string>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
@@ -107,7 +107,7 @@ void MprisController::on_bus_connected(const Glib::RefPtr<Gio::AsyncResult> &res
|
||||
try {
|
||||
auto list_names_result = m_dbus_proxy->call_sync("ListNames");
|
||||
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()) {
|
||||
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<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));
|
||||
|
||||
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<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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<double>();
|
||||
dw.precipitation_sum = daily["precipitation_sum"][i].get<double>();
|
||||
dw.weather_code = daily["weather_code"][i].get<int>();
|
||||
auto time_str = daily["time"][i].get<std::string>();
|
||||
std::tm tm = {};
|
||||
auto time_str = daily["time"][i].get<std::string>();
|
||||
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<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.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) {
|
||||
|
||||
Reference in New Issue
Block a user