Compare commits

...

3 Commits

62 changed files with 974 additions and 1029 deletions

34
.clang-tidy Normal file
View File

@@ -0,0 +1,34 @@
Checks: 'clang-analyzer-*,cppcoreguidelines-*,modernize-*,-modernize-use-trailing-return-type'
WarningsAsErrors: true
HeaderFilterRegex: ''
FormatStyle: google
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: '0'
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: '1'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'

View File

@@ -36,8 +36,14 @@ add_library(bar_lib)
target_sources(bar_lib
PUBLIC
src/app.cpp
src/bar/bar.cpp
src/components/mediaPlayer.cpp
src/components/button/iconButton.cpp
src/components/button/textButton.cpp
src/components/button/tabButton.cpp
src/connection/httpConnection.cpp
src/connection/dbus/notification.cpp
src/connection/dbus/mpris.cpp
@@ -49,22 +55,22 @@ target_sources(bar_lib
src/widgets/notification/copyNotification.cpp
src/widgets/notification/notificationWindow.cpp
src/widgets/notification/spotifyNotification.cpp
src/widgets/controlCenter/controlCenter.cpp
src/widgets/controlCenter/mediaWidget.cpp
src/widgets/volumeWidget.cpp
src/widgets/weather.cpp
src/widgets/webWidget.cpp
src/widgets/tray.cpp
src/services/hyprland.cpp
src/services/notificationController.cpp
src/services/textureCache.cpp
src/widgets/tray.cpp
src/widgets/controlCenter/controlCenter.cpp
src/widgets/controlCenter/mediaControl.cpp
src/components/popover.cpp
src/components/workspaceIndicator.cpp
src/components/base/button.cpp
)
include_directories(bar_lib PRIVATE
include
)

View File

@@ -3,9 +3,9 @@
#include <vector>
#include "bar/bar.hpp"
#include "services/hyprland.hpp"
#include "connection/dbus/notification.hpp"
#include "connection/dbus/tray.hpp"
#include "services/hyprland.hpp"
#include "glibmm/refptr.h"
#include "gtkmm/application.h"

View File

@@ -4,12 +4,13 @@
#include <gtkmm.h>
#include <memory>
#include "components/button/iconButton.hpp"
#include "widgets/clock.hpp"
#include "widgets/controlCenter/controlCenter.hpp"
#include "widgets/date.hpp"
#include "widgets/tray.hpp"
#include "widgets/volumeWidget.hpp"
#include "widgets/webWidget.hpp"
#include "widgets/controlCenter/controlCenter.hpp"
class Bar : public Gtk::Window {
public:
@@ -27,13 +28,12 @@ class Bar : public Gtk::Window {
Clock clock;
Date date;
WebWidget homeAssistant{"\uf024", "Home Assistant", "https://home.rivercry.com"};
ControlCenter controlCenter{"\ue062", "Control Center"};
WebWidget homeAssistant{Icon::HOME_ASSISTANT, "Home Assistant", "https://home.rivercry.com"};
ControlCenter controlCenter{Icon::MENU, "Control Center"};
std::shared_ptr<TrayWidget> trayWidget = nullptr;
std::shared_ptr<VolumeWidget> volumeWidget = nullptr;
void setup_ui();
void setup_left_box();
void setup_center_box();

View File

@@ -1,18 +0,0 @@
#pragma once
#include <gtkmm/button.h>
#include "gtkmm/image.h"
#include "sigc++/signal.h"
class Button : public Gtk::Button {
public:
Button(const std::string label);
Button(Gtk::Image &image);
sigc::signal<void()> onClickedSignal;
private:
void on_clicked() {
onClickedSignal.emit();
}
};

View File

@@ -0,0 +1,12 @@
#pragma once
#include <string>
#include "components/button/textButton.hpp"
#include "components/types/icon.hpp"
class IconButton : public TextButton {
public:
IconButton(Icon::Type icon, std::string fontFamilyCss = "materia-icons");
void setIcon(Icon::Type icon);
};

View File

@@ -0,0 +1,9 @@
#pragma once
#include "components/button/iconButton.hpp"
class TabButton : public IconButton {
public:
TabButton(Icon::Type icon);
void setActive(bool active);
};

View File

@@ -0,0 +1,11 @@
#pragma once
#include <string>
#include "gtkmm/button.h"
class TextButton : public Gtk::Button {
public:
TextButton(const std::string &label);
void setText(const std::string &text);
};

View File

@@ -1,17 +1,17 @@
#pragma once
#include "components/button/iconButton.hpp"
#include "connection/dbus/mpris.hpp"
#include "gtkmm/box.h"
#include "gtkmm/button.h"
#include "gtkmm/label.h"
#include "gtkmm/overlay.h"
#include "gtkmm/picture.h"
#include "gtkmm/scale.h"
#include "gtkmm/scrolledwindow.h"
#include "connection/dbus/mpris.hpp"
class MediaControlWidget : public Gtk::Box {
class MediaPlayer : public Gtk::Box {
public:
explicit MediaControlWidget(std::shared_ptr<MprisController> controller);
explicit MediaPlayer(std::shared_ptr<MprisController> controller);
private:
std::shared_ptr<MprisController> mprisController;
@@ -31,8 +31,6 @@ class MediaControlWidget : public Gtk::Box {
void schedulePauseAfterSeek();
void setCanSeek(bool can_seek);
Gtk::Box spotifyContainer;
// image as background, artist, title
Gtk::Overlay topContainer;
Gtk::Picture backgroundImage;
@@ -48,9 +46,9 @@ class MediaControlWidget : public Gtk::Box {
// playback controls
Gtk::Box bottomContainer;
Gtk::Button previousButton;
Gtk::Button playPauseButton;
Gtk::Button nextButton;
std::unique_ptr<IconButton> previousButton;
std::unique_ptr<IconButton> playPauseButton;
std::unique_ptr<IconButton> nextButton;
Gtk::ScrolledWindow imageWrapper;

View File

@@ -3,11 +3,13 @@
#include <gtkmm/button.h>
#include <gtkmm/popover.h>
#include <string>
#include "components/base/button.hpp"
class Popover : public Button {
#include "components/button/iconButton.hpp"
#include "components/button/textButton.hpp"
class Popover : public IconButton {
public:
Popover(const std::string icon, std::string name);
Popover(Icon::Type icon, std::string name);
~Popover() override;
protected:

View File

@@ -0,0 +1 @@
#pragma once

View File

@@ -0,0 +1,50 @@
#include <fcntl.h>
#include <map>
#include <string>
class Icon {
public:
enum Type {
HOME_ASSISTANT,
MENU,
SKIP_PREVIOUS,
SKIP_NEXT,
PLAY_ARROW,
PAUSE,
PLAY_CIRCLE,
EMPTY_DASHBOARD,
SAVE,
CONTENT_COPY,
TOKEN,
};
static const std::string toString(Type type) {
return typeToString[type];
}
private:
static inline std::map<Type, const std::string> typeToString = {
{HOME_ASSISTANT, "\uf024"},
{MENU, "\ue5d2"},
{SKIP_PREVIOUS, "\ue045"},
{SKIP_NEXT, "\ue044"},
{PLAY_ARROW, "\ue037"},
{PAUSE, "\ue034"},
{PLAY_CIRCLE, "\ue1c4"},
{EMPTY_DASHBOARD, "\uf844"},
{SAVE, "\ue161"},
{CONTENT_COPY, "\ue14d"},
{TOKEN, "\uea25"},
};
};

View File

@@ -8,7 +8,6 @@
class WorkspaceIndicator : public Gtk::Box {
public:
enum InidicatorState {
EMPTY,
ALIVE,

View File

@@ -7,6 +7,7 @@
#include <string>
#include <sys/types.h>
#include <vector>
#include "gdkmm/pixbuf.h"
#include "glibmm/variant.h"

View File

@@ -2,9 +2,10 @@
#include <cstdint>
#include <giomm.h>
#include <sigc++/sigc++.h>
#include <set>
#include <sigc++/sigc++.h>
#include <vector>
#include "connection/dbus/dbus.hpp"
#include "connection/dbus/messages.hpp"

View File

@@ -6,6 +6,7 @@
#include <sigc++/sigc++.h>
#include "connection/dbus/dbus.hpp"
#include "giomm/dbusconnection.h"
#include "giomm/dbusownname.h"
#include "glib.h"

View File

@@ -19,6 +19,7 @@
class TrayService : public DbusConnection {
inline static TrayService *instance = nullptr;
public:
struct Item {
std::string id;

View File

@@ -1,10 +1,10 @@
#pragma once
#include <array>
#include <cstdio>
#include <memory>
#include <stdexcept>
#include <string>
#include <cstdio>
class CommandHelper {
public:

View File

@@ -1,52 +1,15 @@
#pragma once
#include <algorithm>
#include <array>
#include <cassert>
#include <cstring>
#include <span>
#include <nlohmann/json.hpp>
#include <string>
#include <sys/socket.h>
#include "helpers/command.hpp"
class HyprctlHelper {
public:
static nlohmann::json getMonitorData() {
std::string result = CommandHelper::exec("hyprctl -j monitors");
assert(!result.empty() && "Failed to get monitor data from hyprctl");
auto json = nlohmann::json::parse(result);
assert(json.is_array());
return json;
}
static nlohmann::json getWorkspaceData() {
std::string result = CommandHelper::exec("hyprctl -j workspaces");
assert(!result.empty() && "Failed to get workspace data from hyprctl");
auto json = nlohmann::json::parse(result);
assert(json.is_array());
return json;
}
static nlohmann::json getClientData() {
std::string result = CommandHelper::exec("hyprctl -j clients");
assert(!result.empty() && "Failed to get client data from hyprctl");
auto json = nlohmann::json::parse(result);
assert(json.is_array());
return json;
}
static void dispatchWorkspace(int workspaceNumber) {
std::string out = "hyprctl dispatch workspace " + std::to_string(workspaceNumber);
CommandHelper::execNoOutput(out.c_str());
}
};
#include <sys/un.h>
#include <unistd.h>
class HyprSocketHelper {
public:
@@ -66,4 +29,105 @@ class HyprSocketHelper {
return std::string();
}
static std::string getHyprlandCommandSocketPath() {
const char *hyprlandInstanceSignature = std::getenv("HYPRLAND_INSTANCE_SIGNATURE");
const char *xdgRuntimeDir = std::getenv("XDG_RUNTIME_DIR");
if (!xdgRuntimeDir || !hyprlandInstanceSignature) {
return std::string();
}
std::string basePath = std::string(xdgRuntimeDir) + "/hypr/" + std::string(hyprlandInstanceSignature) + "/";
std::string sock1 = basePath + ".socket.sock";
if (access(sock1.c_str(), F_OK) == 0) {
return sock1;
}
return std::string();
}
};
class HyprctlHelper {
public:
static std::string sendCommand(const std::string &command) {
std::string socketPath = HyprSocketHelper::getHyprlandCommandSocketPath();
assert(!socketPath.empty() && "Failed to get Hyprland command socket path");
int socketFd = socket(AF_UNIX, SOCK_STREAM, 0);
assert(socketFd != -1 && "Failed to create Hyprland command socket");
struct sockaddr_un addr {};
std::memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
auto sunPathSpan = std::span<char, sizeof(addr.sun_path)>(addr.sun_path);
std::ranges::fill(sunPathSpan, '\0');
constexpr size_t kMaxPathLength = sizeof(addr.sun_path) - 1;
const size_t copyLength = std::min(socketPath.size(), kMaxPathLength);
std::copy_n(socketPath.begin(), copyLength, sunPathSpan.begin());
auto *sockaddrPtr = static_cast<struct sockaddr *>(static_cast<void *>(&addr));
int result = connect(socketFd, sockaddrPtr, sizeof(addr));
assert(result != -1 && "Failed to connect to Hyprland command socket");
ssize_t bytesSent = send(socketFd, command.c_str(), command.size(), 0);
assert(bytesSent != -1 && "Failed to send command to Hyprland socket");
shutdown(socketFd, SHUT_WR);
std::string response;
constexpr size_t kBufferSize = 4096;
std::array<char, kBufferSize> buffer {};
while (true) {
ssize_t bytesRead = recv(socketFd, buffer.data(), buffer.size(), 0);
if (bytesRead <= 0) {
break;
}
response.append(buffer.data(), static_cast<size_t>(bytesRead));
}
close(socketFd);
return response;
}
static nlohmann::json getMonitorData() {
std::string result = sendCommand("j/monitors");
assert(!result.empty() && "Failed to get monitor data from Hyprland socket");
auto json = nlohmann::json::parse(result);
assert(json.is_array());
return json;
}
static nlohmann::json getWorkspaceData() {
std::string result = sendCommand("j/workspaces");
assert(!result.empty() && "Failed to get workspace data from Hyprland socket");
auto json = nlohmann::json::parse(result);
assert(json.is_array());
return json;
}
static nlohmann::json getClientData() {
std::string result = sendCommand("j/clients");
assert(!result.empty() && "Failed to get client data from Hyprland socket");
auto json = nlohmann::json::parse(result);
assert(json.is_array());
return json;
}
static void dispatchWorkspace(int workspaceNumber) {
std::string command = "dispatch workspace " + std::to_string(workspaceNumber);
sendCommand(command);
}
};

View File

@@ -3,7 +3,6 @@
#include <string>
#include <vector>
class StringHelper {
public:
static std::vector<std::string> split(const std::string &input, char delimiter) {

View File

View File

@@ -6,8 +6,6 @@
#include "components/base/button.hpp"
class BluetoothEntry : Gtk::Box {
public:
BluetoothEntry(std::string name, std::string address) {
@@ -38,7 +36,6 @@ class BluetoothEntry : Gtk::Box {
sigc::signal<void(std::string)> connect_clicked;
};
class BluetoothWidget : public Gtk::Box {
public:
BluetoothWidget();

View File

@@ -1,32 +1,36 @@
#pragma once
#include <memory>
#include "components/button/iconButton.hpp"
#include "components/button/tabButton.hpp"
#include "components/popover.hpp"
#include "gtkmm/box.h"
#include "gtkmm/button.h"
#include "gtkmm/label.h"
#include "gtkmm/stack.h"
#include "widgets/controlCenter/mediaControl.hpp"
#include "widgets/controlCenter/mediaWidget.hpp"
#include "widgets/weather.hpp"
#include <unordered_map>
#include "gtkmm/box.h"
#include "gtkmm/scrolledwindow.h"
#include "gtkmm/stack.h"
class ControlCenter : public Popover {
public:
ControlCenter(std::string icon, std::string name);
ControlCenter(Icon::Type icon, std::string name);
private:
Gtk::ScrolledWindow scrollview;
Gtk::Box container;
Gtk::Box tabRow;
Gtk::Stack contentStack;
Gtk::Box controlCenterContainer;
WeatherWidget weatherWidget;
Gtk::Button mediaControl;
Gtk::Button testTabButton;
std::shared_ptr<MprisController> mprisController = MprisController::getInstance();
std::unordered_map<std::string, MediaControlWidget*> mediaWidgets;
std::unique_ptr<TabButton> mediaTabButton;
std::unique_ptr<TabButton> infoTabButton;
std::unique_ptr<TabButton> timerButton;
std::unique_ptr<WeatherWidget> weatherWidget;
std::unique_ptr<MediaWidget> mediaControlWidget;
void addPlayerWidget(const std::string &bus_name);
void removePlayerWidget(const std::string &bus_name);
void setActiveTab(const std::string &tab_name);
};

View File

@@ -0,0 +1,24 @@
#pragma once
#include "components/mediaPlayer.hpp"
#include <map>
#include <memory>
#include <string>
#include "connection/dbus/mpris.hpp"
#include "gtkmm/box.h"
class MediaWidget : public Gtk::Box {
public:
MediaWidget();
private:
Gtk::Box container;
std::shared_ptr<MprisController> mprisController = MprisController::getInstance();
void addPlayerWidget(const std::string &bus_name);
void removePlayerWidget(const std::string &bus_name);
std::map<std::string, std::unique_ptr<MediaPlayer>> mediaWidgets;
};

View File

@@ -1,12 +1,10 @@
#pragma once
#include <chrono>
#include <csignal>
#include <cstdint>
#include <sigc++/connection.h>
#include "gdkmm/monitor.h"
#include "gtkmm/scrolledwindow.h"
#include "gtkmm/window.h"
#define DEFAULT_NOTIFICATION_TIMEOUT 6700
@@ -19,16 +17,29 @@ class BaseNotification : public Gtk::Window {
void resumeAutoClose();
void startAutoClose(int timeoutMs);
sigc::signal<void(int)> signal_close;
sigc::signal<void(bool)> signal_hover_changed;
virtual ~BaseNotification() = default;
uint64_t getNotificationId() const {
return this->notificationId;
}
sigc::signal<void(uint64_t)> getSignalClose() {
return this->signalClose;
}
sigc::signal<void(bool)> getSignalHoverChanged() {
return this->signalHoverChanged;
}
private:
sigc::signal<void(uint64_t)> signalClose;
sigc::signal<void(bool)> signalHoverChanged;
uint64_t notificationId;
bool autoClosePaused = false;
int autoCloseRemainingMs = 0;
std::chrono::steady_clock::time_point autoCloseDeadline;
sigc::connection autoCloseConnection;
void ensure_notification_css_loaded();
void start_auto_close_timeout(int timeoutMs);
@@ -36,10 +47,15 @@ class BaseNotification : public Gtk::Window {
void resume_auto_close();
protected:
uint64_t notificationId;
bool getAutoClosePaused() const {
return this->autoClosePaused;
}
bool autoClosePaused = false;
int autoCloseRemainingMs = 0;
std::chrono::steady_clock::time_point autoCloseDeadline;
sigc::connection autoCloseConnection;
int getAutoCloseRemainingMs() const {
return this->autoCloseRemainingMs;
}
std::chrono::steady_clock::time_point getAutoCloseDeadline() const {
return this->autoCloseDeadline;
}
};

View File

@@ -4,6 +4,7 @@
#include "connection/dbus/messages.hpp"
#include "widgets/notification/baseNotification.hpp"
#include "gtkmm/box.h"
class CopyNotification : public BaseNotification {

View File

@@ -2,6 +2,7 @@
#pragma once
#include <cstdint>
#include "connection/dbus/messages.hpp"
#include "widgets/notification/baseNotification.hpp"
@@ -9,5 +10,4 @@ class NotificationWindow : public BaseNotification {
public:
NotificationWindow(uint64_t notificationId, std::shared_ptr<Gdk::Monitor> monitor, NotifyMessage message);
virtual ~NotificationWindow() = default;
};

View File

@@ -17,12 +17,12 @@
#include <string>
#include <vector>
#include "components/button/iconButton.hpp"
#include "connection/dbus/tray.hpp"
#include "components/base/button.hpp"
class TrayIconWidget : public Button {
class TrayIconWidget : public IconButton {
public:
TrayIconWidget(std::string id);
TrayIconWidget(Icon::Type icon, std::string id);
~TrayIconWidget() override;
void update(const TrayService::Item &item);

View File

@@ -3,9 +3,10 @@
#include <gtkmm/button.h>
#include <gtkmm/popover.h>
#include "components/button/iconButton.hpp"
#include "components/popover.hpp"
class WebWidget : public Popover {
public:
WebWidget(std::string icon, std::string title, std::string url);
WebWidget(Icon::Type icon, std::string title, std::string url);
};

View File

@@ -7,43 +7,33 @@
:root {
--icon-font-material: "Material Icons", sans-serif;
--icon-font-awesome: "Font Awesome 7 Free", sans-serif;
--text-font: "Hack Nerd Font Mono", sans-serif;
--text-font: "Hack Nerd Font", sans-serif;
--text-font-mono: "Hack Nerd Font Mono", monospace;
}
window {
background-color: #191919c6;
color: #ffffff;
padding-left: 4px;
padding-right: 4px;
padding-bottom: 2px;
font-size: 14px;
font-family: var(--text-font);
padding: 2px 6px;
}
.material-icons {
font-family: var(--icon-font-material);
font-size: 18px;
}
.icon-button {
font-size: 20px;
}
.tab-icon {
font-family: var(--icon-font-material);
font-size: 20px;
margin-right: 6px;
border-radius: 4px;
border: 1px solid transparent;
padding: 2px 4px;
}
.tab-icon:hover {
background-color: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
}
.control-center-tab-row {
/* mordern and sleek */
background-color: rgba(50, 50, 50, 0.8);
border-radius: 8px;
border-radius: 4px;
padding: 2px 4px;
margin-bottom: 4px;
}
@@ -58,26 +48,24 @@ window {
popover {
margin-top: 4px;
font-family: var(--text-font);
/* padding: 6px; TODO: create better padding*/
border-radius: 8px;
border-radius: 4px;
background: rgba(25, 25, 25, 0.8);
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
border: 1px solid rgba(57, 57, 57, 0.71);
font-size: 14px;
}
.control-center-popover {
background-color: rgba(35, 35, 35, 0.95);
padding: 12px;
padding-top : 6px;
border-radius: 8px;
border-radius: 4px;
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
border: 1px solid rgba(57, 57, 57, 0.8);
}
.control-center-player-container {
border-radius: 8px;
border-radius: 4px;
background: rgba(35, 35, 35, 0.95);
margin-bottom: 6px;
}
@@ -105,8 +93,6 @@ popover {
}
.control-center-seek-bar {
min-height: 6px;
min-width: 120px;
margin: 0 6px;
border-bottom: 1px solid var(--color-border);
}
@@ -138,9 +124,14 @@ tooltip {
font-size: 12px;
}
button {
font-size: 20px;
padding: 3px 6px;
.button {
font-size: 14px;
padding: 4px 8px;
border-radius: 4px;
transition:
background-color 0.2s,
color 0.2s,
border-color 0.2s;
}
#spacer {
@@ -151,20 +142,14 @@ button {
}
.button:hover {
background-color: #111111;
}
.flat-button {
background-color: #333333;
color: #ffffff;
padding: 2px 4px;
border-radius: 10px;
background-color: rgba(255, 255, 255, 0.1);
box-shadow: none;
}
.workspace-pill {
padding: 2px 5px;
margin-right: 6px;
border-radius: 5px;
border-radius: 4px;
text-shadow: 0 0 2px #646464;
transition:
background-color 0.2s,

View File

@@ -2,8 +2,9 @@
#include <sigc++/sigc++.h>
#include <vector>
#include "connection/dbus/notification.hpp"
#include "connection/dbus/mpris.hpp"
#include "connection/dbus/notification.hpp"
#include "services/notificationController.hpp"
#include "services/textureCache.hpp"
@@ -26,8 +27,7 @@ App::App() {
for (guint i = 0; i < monitors->get_n_items(); ++i) {
auto monitor = std::dynamic_pointer_cast<Gdk::Monitor>(
monitors->get_object(i)
);
monitors->get_object(i));
if (monitor) {
auto bar = std::make_shared<Bar>(monitor->gobj());
@@ -44,7 +44,6 @@ App::App() {
}
});
app->signal_shutdown().connect([&]() {
this->trayService->stop();
});

View File

@@ -5,6 +5,7 @@
#include <gtkmm/label.h>
#include <gtkmm/window.h>
#include "components/button/textButton.hpp"
#include "helpers/system.hpp"
#include "widgets/date.hpp"
#include "widgets/spacer.hpp"

View File

@@ -1,14 +0,0 @@
#include "components/base/button.hpp"
#include "sigc++/functors/mem_fun.h"
Button::Button(const std::string label) : Gtk::Button(label) {
signal_clicked().connect(sigc::mem_fun(*this, &Button::on_clicked));
this->add_css_class("button");
}
Button::Button(Gtk::Image &image) : Gtk::Button() {
set_child(image);
signal_clicked().connect(sigc::mem_fun(*this, &Button::on_clicked));
this->add_css_class("button");
}

View File

@@ -0,0 +1,10 @@
#include "components/button/iconButton.hpp"
IconButton::IconButton(Icon::Type icon, std::string fontFamilyCss) : TextButton(Icon::toString(icon)) {
this->get_style_context()->add_class(fontFamilyCss);
this->add_css_class("icon-button");
}
void IconButton::setIcon(Icon::Type icon) {
this->set_label(Icon::toString(icon));
}

View File

@@ -0,0 +1,13 @@
#include "components/button/tabButton.hpp"
TabButton::TabButton(Icon::Type icon) : IconButton(icon) {
add_css_class("tab-icon");
}
void TabButton::setActive(bool active) {
if (active) {
this->add_css_class("active-button");
} else {
this->remove_css_class("active-button");
}
}

View File

@@ -0,0 +1,9 @@
#include "components/button/textButton.hpp"
TextButton::TextButton(const std::string &label) : Gtk::Button(label) {
add_css_class("button");
}
void TextButton::setText(const std::string &text) {
this->set_label(text);
}

View File

@@ -1,15 +1,32 @@
#include "widgets/controlCenter/mediaControl.hpp"
#include "components/mediaPlayer.hpp"
#include "components/button/iconButton.hpp"
#include "helpers/string.hpp"
#include "services/textureCache.hpp"
MediaControlWidget::MediaControlWidget(std::shared_ptr<MprisController> controller)
: Gtk::Box(Gtk::Orientation::VERTICAL) {
namespace {
std::string formatTimeUs(int64_t time_us) {
if (time_us < 0) {
time_us = 0;
}
int64_t totalSeconds = time_us / 1000000;
int64_t hours = totalSeconds / 3600;
int64_t minutes = (totalSeconds / 60) % 60;
int64_t seconds = totalSeconds % 60;
this->mprisController = std::move(controller);
if (hours > 0) {
return std::to_string(hours) + ":" +
(minutes < 10 ? "0" : "") + std::to_string(minutes) + ":" +
(seconds < 10 ? "0" : "") + std::to_string(seconds);
}
return std::to_string(minutes) + ":" + (seconds < 10 ? "0" : "") + std::to_string(seconds);
}
} // namespace
MediaPlayer::MediaPlayer(std::shared_ptr<MprisController> controller)
: Gtk::Box(Gtk::Orientation::VERTICAL), mprisController(controller) {
this->set_orientation(Gtk::Orientation::VERTICAL);
this->set_size_request(200, -1);
this->set_hexpand(false);
this->set_vexpand(false);
this->add_css_class("control-center-player-container");
@@ -88,6 +105,10 @@ MediaControlWidget::MediaControlWidget(std::shared_ptr<MprisController> controll
}
});
this->previousButton = std::make_unique<IconButton>(Icon::SKIP_PREVIOUS);
this->playPauseButton = std::make_unique<IconButton>(Icon::PLAY_ARROW);
this->nextButton = std::make_unique<IconButton>(Icon::SKIP_NEXT);
this->bottomContainer.set_orientation(Gtk::Orientation::HORIZONTAL);
this->bottomContainer.set_vexpand(false);
this->bottomContainer.set_hexpand(false);
@@ -95,31 +116,22 @@ MediaControlWidget::MediaControlWidget(std::shared_ptr<MprisController> controll
this->bottomContainer.set_homogeneous(true);
this->topContainer.set_vexpand(false);
this->topContainer.set_hexpand(true);
this->bottomContainer.append(this->previousButton);
this->bottomContainer.append(this->playPauseButton);
this->bottomContainer.append(this->nextButton);
this->bottomContainer.append(*this->previousButton);
this->bottomContainer.append(*this->playPauseButton);
this->bottomContainer.append(*this->nextButton);
this->previousButton.set_label("\u23EE"); // Previous track symbol
this->previousButton.add_css_class("button");
this->previousButton.add_css_class("material-icons");
this->playPauseButton.set_label("\u23EF"); // Play/Pause symbol
this->playPauseButton.add_css_class("button");
this->playPauseButton.add_css_class("material-icons");
this->nextButton.set_label("\u23ED"); // Next track symbol
this->nextButton.add_css_class("button");
this->nextButton.add_css_class("material-icons");
this->previousButton.signal_clicked().connect([this]() {
this->previousButton->signal_clicked().connect([this]() {
this->mprisController->previous_song();
});
this->playPauseButton.signal_clicked().connect([this]() {
this->playPauseButton->signal_clicked().connect([this]() {
this->mprisController->toggle_play();
});
this->nextButton.signal_clicked().connect([this]() {
this->nextButton->signal_clicked().connect([this]() {
this->mprisController->next_song();
});
this->mprisController->signal_mpris_updated().connect(
sigc::mem_fun(*this, &MediaControlWidget::onSpotifyMprisUpdated));
sigc::mem_fun(*this, &MediaPlayer::onSpotifyMprisUpdated));
this->mprisController->signal_playback_status_changed().connect(
[this](MprisController::PlaybackStatus status) {
@@ -144,12 +156,12 @@ MediaControlWidget::MediaControlWidget(std::shared_ptr<MprisController> controll
this->resetSeekTimer(0);
}
void MediaControlWidget::setCanSeek(bool can_seek) {
void MediaPlayer::setCanSeek(bool can_seek) {
this->canSeek = can_seek;
this->seekBarContainer.set_visible(can_seek);
}
void MediaControlWidget::onSpotifyMprisUpdated(const MprisPlayer2Message &message) {
void MediaPlayer::onSpotifyMprisUpdated(const MprisPlayer2Message &message) {
std::string artistText = "Unknown Artist";
if (!message.artist.empty()) {
artistText = StringHelper::trimToSize(message.artist[0], 30);
@@ -177,12 +189,9 @@ void MediaControlWidget::onSpotifyMprisUpdated(const MprisPlayer2Message &messag
}
}
void MediaControlWidget::setCurrentPosition(int64_t position_us) {
void MediaPlayer::setCurrentPosition(int64_t position_us) {
this->currentPositionUs = position_us;
int64_t seconds = (position_us / 1000000) % 60;
int64_t minutes = (position_us / (1000000 * 60)) % 60;
this->currentTimeLabel.set_text(
std::to_string(minutes) + ":" + (seconds < 10 ? "0" : "") + std::to_string(seconds));
this->currentTimeLabel.set_text(formatTimeUs(position_us));
if (totalLengthUs > 0) {
double fraction = static_cast<double>(currentPositionUs) / static_cast<double>(totalLengthUs);
this->suppressSeekSignal = true;
@@ -191,15 +200,12 @@ void MediaControlWidget::setCurrentPosition(int64_t position_us) {
}
}
void MediaControlWidget::setTotalLength(int64_t length_us) {
void MediaPlayer::setTotalLength(int64_t length_us) {
this->totalLengthUs = length_us;
int64_t seconds = (length_us / 1000000) % 60;
int64_t minutes = (length_us / (1000000 * 60)) % 60;
this->totalTimeLabel.set_text(
std::to_string(minutes) + ":" + (seconds < 10 ? "0" : "") + std::to_string(seconds));
this->totalTimeLabel.set_text(formatTimeUs(length_us));
}
void MediaControlWidget::resetSeekTimer(int64_t start_position_us) {
void MediaPlayer::resetSeekTimer(int64_t start_position_us) {
if (seekTimerConnection.connected()) {
seekTimerConnection.disconnect();
}
@@ -207,19 +213,20 @@ void MediaControlWidget::resetSeekTimer(int64_t start_position_us) {
setCurrentPosition(start_position_us);
seekTimerConnection = Glib::signal_timeout().connect(
sigc::mem_fun(*this, &MediaControlWidget::onSeekTick),
sigc::mem_fun(*this, &MediaPlayer::onSeekTick),
1000);
}
void MediaControlWidget::schedulePauseAfterSeek() {
void MediaPlayer::schedulePauseAfterSeek() {
Glib::signal_timeout().connect_once([this]() {
if (this->playbackStatus != MprisController::PlaybackStatus::Playing) {
this->mprisController->pause();
}
}, 100);
},
100);
}
bool MediaControlWidget::onSeekTick() {
bool MediaPlayer::onSeekTick() {
if (totalLengthUs <= 0) {
return true;
}
@@ -232,7 +239,7 @@ bool MediaControlWidget::onSeekTick() {
return true;
}
void MediaControlWidget::onRunningStateChanged(MprisController::PlaybackStatus status) {
void MediaPlayer::onRunningStateChanged(MprisController::PlaybackStatus status) {
this->playbackStatus = status;
switch (status) {
case MprisController::PlaybackStatus::Playing:
@@ -247,21 +254,22 @@ void MediaControlWidget::onRunningStateChanged(MprisController::PlaybackStatus s
}
}
void MediaControlWidget::onPlay() {
this->playPauseButton.set_label("\u23F8"); // Pause symbol
// strart seek timer if not already running
void MediaPlayer::onPlay() {
this->playPauseButton->setIcon(Icon::PAUSE);
this->resetSeekTimer(currentPositionUs);
}
void MediaControlWidget::onPause() {
this->playPauseButton.set_label("\u23F5"); // Play symbol
void MediaPlayer::onPause() {
this->playPauseButton->setIcon(Icon::PLAY_ARROW);
if (seekTimerConnection.connected()) {
seekTimerConnection.disconnect();
}
}
void MediaControlWidget::onStop() {
this->playPauseButton.set_label("\u23F9"); // stop symbol
void MediaPlayer::onStop() {
this->playPauseButton->setIcon(Icon::PLAY_ARROW);
if (seekTimerConnection.connected()) {
seekTimerConnection.disconnect();
}

View File

@@ -0,0 +1,277 @@
#include "components/mediaPlayer.hpp"
#include "components/button/iconButton.hpp"
#include "helpers/string.hpp"
#include "services/textureCache.hpp"
namespace {
std::string formatTimeUs(int64_t time_us) {
if (time_us < 0) {
time_us = 0;
}
int64_t totalSeconds = time_us / 1000000;
int64_t hours = totalSeconds / 3600;
int64_t minutes = (totalSeconds / 60) % 60;
int64_t seconds = totalSeconds % 60;
if (hours > 0) {
return std::to_string(hours) + ":" +
(minutes < 10 ? "0" : "") + std::to_string(minutes) + ":" +
(seconds < 10 ? "0" : "") + std::to_string(seconds);
}
return std::to_string(minutes) + ":" + (seconds < 10 ? "0" : "") + std::to_string(seconds);
}
} // namespace
MediaPlayer::MediaPlayer(std::shared_ptr<MprisController> controller)
: Gtk::Box(Gtk::Orientation::VERTICAL), mprisController(controller) {
this->set_orientation(Gtk::Orientation::VERTICAL);
this->set_hexpand(false);
this->set_vexpand(false);
this->add_css_class("control-center-player-container");
this->append(this->topContainer);
this->append(this->seekBarContainer);
this->append(this->bottomContainer);
this->backgroundImage.set_content_fit(Gtk::ContentFit::COVER);
this->backgroundImage.set_can_shrink(true);
this->imageWrapper.set_policy(Gtk::PolicyType::NEVER, Gtk::PolicyType::NEVER);
this->imageWrapper.set_child(this->backgroundImage);
this->topContainer.set_child(this->imageWrapper);
this->topContainer.set_size_request(-1, 120);
this->topContainer.set_vexpand(false);
this->topContainer.set_hexpand(true);
this->infoContainer.set_orientation(Gtk::Orientation::VERTICAL);
this->infoContainer.set_valign(Gtk::Align::END);
this->infoContainer.set_halign(Gtk::Align::START);
this->infoContainer.append(this->artistLabel);
this->infoContainer.append(this->titleLabel);
this->topContainer.add_overlay(this->infoContainer);
this->artistLabel.set_halign(Gtk::Align::START);
this->titleLabel.set_halign(Gtk::Align::START);
this->seekBarContainer.set_orientation(Gtk::Orientation::HORIZONTAL);
this->seekBarContainer.set_vexpand(false);
this->seekBarContainer.set_hexpand(true);
this->seekBarContainer.set_halign(Gtk::Align::CENTER);
this->seekBarContainer.append(this->currentTimeLabel);
this->seekBarContainer.append(this->seekBar);
this->seekBarContainer.append(this->totalTimeLabel);
this->seekBarContainer.set_visible(true);
this->currentTimeLabel.set_text("0:00");
this->currentTimeLabel.set_halign(Gtk::Align::START);
this->totalTimeLabel.set_text("0:00");
this->totalTimeLabel.set_halign(Gtk::Align::END);
this->seekBar.set_range(0, 100);
this->seekBar.set_value(0);
this->seekBar.set_orientation(Gtk::Orientation::HORIZONTAL);
this->seekBar.set_draw_value(false);
this->seekBar.set_hexpand(true);
this->seekBar.set_halign(Gtk::Align::CENTER);
this->seekBar.add_css_class("control-center-seek-bar");
this->seekBar.signal_value_changed().connect([this]() {
if (this->suppressSeekSignal || this->totalLengthUs <= 0) {
return;
}
double fraction = this->seekBar.get_value() / 100.0;
int64_t new_position_us =
static_cast<int64_t>(fraction * static_cast<double>(this->totalLengthUs));
if (new_position_us == this->currentPositionUs) {
return;
}
if (!this->currentTrackId.empty()) {
this->mprisController->set_position(this->currentTrackId, new_position_us);
if (this->playbackStatus != MprisController::PlaybackStatus::Playing) {
this->schedulePauseAfterSeek();
}
} else if (this->playbackStatus == MprisController::PlaybackStatus::Playing) {
this->mprisController->emit_seeked(new_position_us - this->currentPositionUs); // in us
} else {
return;
}
if (this->playbackStatus == MprisController::PlaybackStatus::Playing) {
this->resetSeekTimer(new_position_us);
} else {
this->setCurrentPosition(new_position_us);
}
});
this->previousButton = std::make_unique<IconButton>(Icon::SKIP_PREVIOUS);
this->playPauseButton = std::make_unique<IconButton>(Icon::PLAY_ARROW);
this->nextButton = std::make_unique<IconButton>(Icon::SKIP_NEXT);
this->bottomContainer.set_orientation(Gtk::Orientation::HORIZONTAL);
this->bottomContainer.set_vexpand(false);
this->bottomContainer.set_hexpand(false);
this->bottomContainer.set_valign(Gtk::Align::START);
this->bottomContainer.set_homogeneous(true);
this->topContainer.set_vexpand(false);
this->topContainer.set_hexpand(true);
this->bottomContainer.append(*this->previousButton);
this->bottomContainer.append(*this->playPauseButton);
this->bottomContainer.append(*this->nextButton);
this->previousButton->signal_clicked().connect([this]() {
this->mprisController->previous_song();
});
this->playPauseButton->signal_clicked().connect([this]() {
this->mprisController->toggle_play();
});
this->nextButton->signal_clicked().connect([this]() {
this->mprisController->next_song();
});
this->mprisController->signal_mpris_updated().connect(
sigc::mem_fun(*this, &MediaPlayer::onSpotifyMprisUpdated));
this->mprisController->signal_playback_status_changed().connect(
[this](MprisController::PlaybackStatus status) {
this->onRunningStateChanged(status);
});
this->mprisController->signal_playback_position_changed().connect(
[this](int64_t position_us) {
this->setCurrentPosition(position_us);
});
this->mprisController->signal_can_seek_changed().connect(
[this](bool can_seek) {
this->setCanSeek(can_seek);
});
this->artistLabel.set_text("Artist Name");
this->artistLabel.add_css_class("control-center-player-artist-label");
this->titleLabel.set_text("Song Title");
this->titleLabel.add_css_class("control-center-player-title-label");
this->resetSeekTimer(0);
}
void MediaPlayer::setCanSeek(bool can_seek) {
this->canSeek = can_seek;
this->seekBarContainer.set_visible(can_seek);
}
void MediaPlayer::onSpotifyMprisUpdated(const MprisPlayer2Message &message) {
std::string artistText = "Unknown Artist";
if (!message.artist.empty()) {
artistText = StringHelper::trimToSize(message.artist[0], 30);
}
this->artistLabel.set_text(artistText);
this->titleLabel.set_text(message.title);
const bool trackChanged = !this->currentTrackId.empty() && this->currentTrackId != message.track_id;
this->currentTrackId = message.track_id;
if (trackChanged) {
this->currentPositionUs = 0;
}
if (auto texture = TextureCacheService::getInstance()->getTexture(message.artwork_url)) {
this->backgroundImage.set_paintable(texture);
}
this->setTotalLength(message.length_ms * 1000);
this->setCurrentPosition(this->currentPositionUs);
if (this->playbackStatus == MprisController::PlaybackStatus::Playing) {
this->resetSeekTimer(this->currentPositionUs);
} else if (seekTimerConnection.connected()) {
seekTimerConnection.disconnect();
}
}
void MediaPlayer::setCurrentPosition(int64_t position_us) {
this->currentPositionUs = position_us;
this->currentTimeLabel.set_text(formatTimeUs(position_us));
if (totalLengthUs > 0) {
double fraction = static_cast<double>(currentPositionUs) / static_cast<double>(totalLengthUs);
this->suppressSeekSignal = true;
this->seekBar.set_value(fraction * 100);
this->suppressSeekSignal = false;
}
}
void MediaPlayer::setTotalLength(int64_t length_us) {
this->totalLengthUs = length_us;
this->totalTimeLabel.set_text(formatTimeUs(length_us));
}
void MediaPlayer::resetSeekTimer(int64_t start_position_us) {
if (seekTimerConnection.connected()) {
seekTimerConnection.disconnect();
}
setCurrentPosition(start_position_us);
seekTimerConnection = Glib::signal_timeout().connect(
sigc::mem_fun(*this, &MediaPlayer::onSeekTick),
1000);
}
void MediaPlayer::schedulePauseAfterSeek() {
Glib::signal_timeout().connect_once([this]() {
if (this->playbackStatus != MprisController::PlaybackStatus::Playing) {
this->mprisController->pause();
}
},
100);
}
bool MediaPlayer::onSeekTick() {
if (totalLengthUs <= 0) {
return true;
}
int64_t nextPosition = currentPositionUs + 1000000;
if (nextPosition > totalLengthUs) {
nextPosition = totalLengthUs;
}
setCurrentPosition(nextPosition);
return true;
}
void MediaPlayer::onRunningStateChanged(MprisController::PlaybackStatus status) {
this->playbackStatus = status;
switch (status) {
case MprisController::PlaybackStatus::Playing:
this->onPlay();
break;
case MprisController::PlaybackStatus::Paused:
this->onPause();
break;
case MprisController::PlaybackStatus::Stopped:
this->onStop();
break;
}
}
void MediaPlayer::onPlay() {
this->playPauseButton->setIcon(Icon::PAUSE);
this->resetSeekTimer(currentPositionUs);
}
void MediaPlayer::onPause() {
this->playPauseButton->setIcon(Icon::PLAY_ARROW);
if (seekTimerConnection.connected()) {
seekTimerConnection.disconnect();
}
}
void MediaPlayer::onStop() {
this->playPauseButton->setIcon(Icon::PLAY_ARROW);
if (seekTimerConnection.connected()) {
seekTimerConnection.disconnect();
}
this->setCurrentPosition(0);
}

View File

@@ -1,6 +1,8 @@
#include "components/popover.hpp"
Popover::Popover(const std::string icon, std::string name): Button(icon) {
#include "components/button/iconButton.hpp"
Popover::Popover(Icon::Type icon, std::string name) : IconButton(icon) {
signal_clicked().connect(sigc::mem_fun(*this, &Popover::on_toggle_window));
set_name(name);

0
src/components/tab.cpp Normal file
View File

View File

@@ -398,10 +398,8 @@ void MprisController::set_position(const std::string &track_id, int64_t position
}
try {
Glib::VariantContainerBase params = Glib::VariantContainerBase::create_tuple({
Glib::Variant<Glib::DBusObjectPathString>::create(track_id),
Glib::Variant<gint64>::create(position_us)
});
Glib::VariantContainerBase params = Glib::VariantContainerBase::create_tuple({Glib::Variant<Glib::DBusObjectPathString>::create(track_id),
Glib::Variant<gint64>::create(position_us)});
m_proxy->call("SetPosition", params);
} catch (const Glib::Error &ex) {

View File

@@ -9,8 +9,8 @@
#include <giomm/dbusactiongroup.h>
#include <giomm/dbusownname.h>
#include <giomm/menumodel.h>
#include <spdlog/spdlog.h>
#include <memory>
#include <spdlog/spdlog.h>
#include <tuple>
#include <vector>

View File

@@ -3,6 +3,7 @@
#include <algorithm>
#include <cctype>
#include <curl/curl.h>
#include <ranges>
#include <string>
#include <utility>
@@ -17,8 +18,8 @@ size_t write_to_string(void *contents, size_t size, size_t nmemb, void *userp) {
std::string trim(std::string value) {
auto not_space = [](unsigned char c) { return std::isspace(c) == 0; };
value.erase(value.begin(),
std::find_if(value.begin(), value.end(), not_space));
value.erase(std::find_if(value.rbegin(), value.rend(), not_space).base(),
std::ranges::find_if(value, not_space));
value.erase(std::ranges::find_if(std::ranges::reverse_view(value), not_space).base(),
value.end());
return value;
}
@@ -38,7 +39,7 @@ size_t header_to_map(char *buffer, size_t size, size_t nitems, void *userdata) {
}
return total;
}
}
} // namespace
HttpResponse HttpConnection::get(const std::string &url,
const std::map<std::string, std::string> &headers,

View File

@@ -14,7 +14,6 @@
#include "helpers/string.hpp"
#include "gtkmm/box.h"
#include "spdlog/spdlog.h"
HyprlandService::HyprlandService() {
@@ -93,7 +92,7 @@ void HyprlandService::bindHyprlandSocket() {
return;
}
struct sockaddr_un addr;
struct sockaddr_un addr{};
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
std::strncpy(addr.sun_path, socketPath.c_str(), sizeof(addr.sun_path) - 1);

View File

@@ -52,11 +52,11 @@ void NotificationController::showNotificationOnAllMonitors(NotifyMessage notify)
timeout = DEFAULT_NOTIFICATION_TIMEOUT;
}
notification->signal_close.connect([this, id = notification->getNotificationId()](int) {
notification->getSignalClose().connect([this, id = notification->getNotificationId()](int) {
closeNotification(id);
});
notification->signal_hover_changed.connect([this, id = notification->getNotificationId()](bool hovered) {
notification->getSignalHoverChanged().connect([this, id = notification->getNotificationId()](bool hovered) {
updateHoverState(id, hovered);
});
@@ -80,11 +80,11 @@ void NotificationController::showCopyNotification(NotifyMessage notify) {
notification->show();
notifications.push_back(notification);
notification->signal_close.connect([this, id = notification->getNotificationId()](int) {
notification->getSignalClose().connect([this, id = notification->getNotificationId()](int) {
closeNotification(id);
});
notification->signal_hover_changed.connect([this, id = notification->getNotificationId()](bool hovered) {
notification->getSignalHoverChanged().connect([this, id = notification->getNotificationId()](bool hovered) {
updateHoverState(id, hovered);
});
notification->startAutoClose(DEFAULT_NOTIFICATION_TIMEOUT);
@@ -103,11 +103,11 @@ void NotificationController::showSpotifyNotification(MprisPlayer2Message mpris)
notification->show();
notifications.push_back(notification);
notification->signal_close.connect([this, id = notification->getNotificationId()](int) {
notification->getSignalClose().connect([this, id = notification->getNotificationId()](int) {
closeNotification(id);
});
notification->signal_hover_changed.connect([this, id = notification->getNotificationId()](bool hovered) {
notification->getSignalHoverChanged().connect([this, id = notification->getNotificationId()](bool hovered) {
updateHoverState(id, hovered);
});

View File

@@ -66,8 +66,7 @@ std::filesystem::path get_cache_path_for_url(const std::string &url) {
std::chrono::system_clock::time_point to_system_clock(std::filesystem::file_time_type time) {
return std::chrono::time_point_cast<std::chrono::system_clock::duration>(
time - std::filesystem::file_time_type::clock::now() + std::chrono::system_clock::now()
);
time - std::filesystem::file_time_type::clock::now() + std::chrono::system_clock::now());
}
size_t write_to_buffer(void *contents, size_t size, size_t nmemb, void *userp) {

View File

View File

@@ -1,101 +1,83 @@
#include "widgets/controlCenter/controlCenter.hpp"
#include "components/button/iconButton.hpp"
#include "components/button/tabButton.hpp"
#include "components/mediaPlayer.hpp"
ControlCenter::ControlCenter(std::string icon, std::string name)
ControlCenter::ControlCenter(Icon::Type icon, std::string name)
: Popover(icon, name) {
this->popover->add_css_class("control-center-popover");
this->container.set_orientation(Gtk::Orientation::VERTICAL);
this->container.set_spacing(10);
this->popover->set_hexpand(false);
this->popover->set_size_request(240, -1);
set_popover_child(this->container);
this->scrollview.set_child(this->container);
this->scrollview.set_policy(
Gtk::PolicyType::NEVER, Gtk::PolicyType::AUTOMATIC);
this->scrollview.set_hexpand(false);
this->scrollview.set_vexpand(true);
this->scrollview.set_propagate_natural_height(true);
set_popover_child(this->scrollview);
this->tabRow.set_orientation(Gtk::Orientation::HORIZONTAL);
this->tabRow.set_spacing(4);
this->tabRow.set_margin_bottom(4);
this->tabRow.add_css_class("control-center-tab-row");
this->mediaControl.set_label("\uf5d3"); // control icon
this->mediaControl.add_css_class("tab-icon");
this->testTabButton.set_label("\uE5CA"); // test icon
this->testTabButton.add_css_class("tab-icon");
this->mediaTabButton = std::make_unique<TabButton>(Icon::PLAY_CIRCLE);
this->infoTabButton = std::make_unique<TabButton>(Icon::EMPTY_DASHBOARD);
this->timerButton = std::make_unique<TabButton>(Icon::TOKEN);
this->tabRow.append(this->mediaControl);
this->tabRow.append(this->testTabButton);
this->tabRow.append(*this->mediaTabButton);
this->tabRow.append(*this->infoTabButton);
this->tabRow.append(*this->timerButton);
this->container.append(this->tabRow);
this->contentStack.set_hhomogeneous(false);
this->contentStack.set_hhomogeneous(true);
this->contentStack.set_vhomogeneous(false);
this->contentStack.set_transition_type(Gtk::StackTransitionType::CROSSFADE);
this->contentStack.set_transition_duration(150);
this->controlCenterContainer.set_orientation(Gtk::Orientation::VERTICAL);
this->controlCenterContainer.set_spacing(4);
this->mediaControlWidget = std::make_unique<MediaWidget>();
this->weatherWidget = std::make_unique<WeatherWidget>();
this->contentStack.add(*this->mediaControlWidget, "controls", "Controls");
this->contentStack.add(*this->weatherWidget, "info", "Info");
this->contentStack.add(*Gtk::make_managed<Gtk::Label>("Timer"), "timer", "Timer");
this->contentStack.add(this->controlCenterContainer, "controls", "Controls");
this->contentStack.add(this->weatherWidget, "test", "Test");
this->contentStack.set_visible_child("controls");
this->setActiveTab("controls");
this->setActiveTab("info");
this->container.append(this->contentStack);
this->mediaControl.signal_clicked().connect([this]() {
this->mediaTabButton->signal_clicked().connect([this]() {
this->setActiveTab("controls");
});
this->testTabButton.signal_clicked().connect([this]() {
this->setActiveTab("test");
this->infoTabButton->signal_clicked().connect([this]() {
this->setActiveTab("info");
});
this->mprisController->signal_player_registered().connect(
[this](const std::string &bus_name) {
this->addPlayerWidget(bus_name);
this->timerButton->signal_clicked().connect([this]() {
this->setActiveTab("timer");
});
this->mprisController->signal_player_deregistered().connect(
[this](const std::string &bus_name) {
this->removePlayerWidget(bus_name);
});
for (const auto &bus_name : this->mprisController->get_registered_players()) {
this->addPlayerWidget(bus_name);
}
}
void ControlCenter::setActiveTab(const std::string &tab_name) {
this->contentStack.set_visible_child(tab_name);
this->mediaControl.remove_css_class("active-button");
this->testTabButton.remove_css_class("active-button");
this->mediaTabButton->setActive(false);
this->infoTabButton->setActive(false);
this->timerButton->setActive(false);
if (tab_name == "controls") {
this->mediaControl.add_css_class("active-button");
} else if (tab_name == "test") {
this->testTabButton.add_css_class("active-button");
this->mediaTabButton->setActive(true);
} else if (tab_name == "info") {
this->infoTabButton->setActive(true);
} else if (tab_name == "timer") {
this->timerButton->setActive(true);
}
}
void ControlCenter::addPlayerWidget(const std::string &bus_name) {
if (this->mediaWidgets.find(bus_name) != this->mediaWidgets.end()) {
return;
}
auto controller = MprisController::createForPlayer(bus_name);
auto widget = Gtk::make_managed<MediaControlWidget>(controller);
this->mediaWidgets.emplace(bus_name, widget);
this->controlCenterContainer.append(*widget);
}
void ControlCenter::removePlayerWidget(const std::string &bus_name) {
auto it = this->mediaWidgets.find(bus_name);
if (it == this->mediaWidgets.end()) {
return;
}
this->controlCenterContainer.remove(*it->second);
this->mediaWidgets.erase(it);
}

View File

@@ -0,0 +1,50 @@
#include "widgets/controlCenter/mediaWidget.hpp"
#include <memory>
MediaWidget::MediaWidget() : Gtk::Box(Gtk::Orientation::VERTICAL) {
this->set_hexpand(true);
this->set_vexpand(false);
this->add_css_class("control-center-media-widget");
this->container.set_orientation(Gtk::Orientation::VERTICAL);
this->container.set_hexpand(true);
this->container.set_vexpand(false);
this->append(this->container);
this->mprisController->signal_player_registered().connect(
[this](const std::string &bus_name) {
this->addPlayerWidget(bus_name);
});
this->mprisController->signal_player_deregistered().connect(
[this](const std::string &bus_name) {
this->removePlayerWidget(bus_name);
});
for (const auto &bus_name : this->mprisController->get_registered_players()) {
this->addPlayerWidget(bus_name);
}
}
void MediaWidget::addPlayerWidget(const std::string &bus_name) {
if (this->mediaWidgets.find(bus_name) != this->mediaWidgets.end()) {
return;
}
auto controller = MprisController::createForPlayer(bus_name);
auto widget = std::make_unique<MediaPlayer>(controller);
this->mediaWidgets.emplace(bus_name, std::move(widget));
this->container.append(*this->mediaWidgets[bus_name]);
}
void MediaWidget::removePlayerWidget(const std::string &bus_name) {
auto it = this->mediaWidgets.find(bus_name);
if (it == this->mediaWidgets.end()) {
return;
}
this->container.remove(*it->second);
this->mediaWidgets.erase(it);
}

View File

@@ -8,7 +8,6 @@
#include "gdkmm/monitor.h"
#include "glibmm/main.h"
#include "glibmm/object.h"
#include "gtk4-layer-shell.h"
#include "gtkmm/button.h"
#include "gtkmm/cssprovider.h"
@@ -42,17 +41,17 @@ BaseNotification::BaseNotification(uint64_t notificationId, std::shared_ptr<Gdk:
return;
}
}
this->signal_close.emit(this->notificationId);
this->getSignalClose().emit(this->notificationId);
});
add_controller(window_click);
auto window_motion = Gtk::EventControllerMotion::create();
window_motion->signal_enter().connect([this](double, double) {
signal_hover_changed.emit(true);
getSignalHoverChanged().emit(true);
pause_auto_close();
});
window_motion->signal_leave().connect([this]() {
signal_hover_changed.emit(false);
getSignalHoverChanged().emit(false);
resume_auto_close();
});
add_controller(window_motion);
@@ -83,7 +82,7 @@ void BaseNotification::start_auto_close_timeout(int timeoutMs) {
autoCloseDeadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(timeoutMs);
autoCloseConnection = Glib::signal_timeout().connect([this]() {
this->signal_close.emit(this->notificationId);
this->getSignalClose().emit(this->notificationId);
return false; // Don't repeat
},
timeoutMs);
@@ -111,7 +110,7 @@ void BaseNotification::resume_auto_close() {
autoClosePaused = false;
if (autoCloseRemainingMs <= 0) {
this->signal_close.emit(this->notificationId);
this->getSignalClose().emit(this->notificationId);
return;
}

View File

@@ -3,6 +3,8 @@
#include <memory>
#include <spdlog/spdlog.h>
#include "components/button/iconButton.hpp"
#include "glibmm/datetime.h"
#include "glibmm/fileutils.h"
#include "glibmm/miscutils.h"
@@ -85,26 +87,19 @@ void CopyNotification::createImageNotification(NotifyMessage notify) {
auto buttonBox = Gtk::make_managed<Gtk::Box>();
buttonBox->set_spacing(10);
// material icons unicode
auto saveToClipboardLabel = Gtk::make_managed<Gtk::Label>("\uF0EA"); // content copy icon
auto saveToFileLabel = Gtk::make_managed<Gtk::Label>("\uF1C5"); // save icon
auto saveToClipboardButton = Gtk::make_managed<Gtk::Button>();
saveToClipboardButton->set_child(*saveToClipboardLabel);
auto saveToClipboardButton = Gtk::make_managed<IconButton>(Icon::CONTENT_COPY);
saveToClipboardButton->signal_clicked().connect([this]() {
copyToClipboard(this->copiedImage);
spdlog::info("Copied image to clipboard");
this->signal_close.emit(this->notificationId);
this->getSignalClose().emit(this->getNotificationId());
});
saveToClipboardButton->set_tooltip_text("Copy to Clipboard");
saveToClipboardButton->add_css_class("notification-button");
saveToClipboardButton->add_css_class("notification-icon-button");
auto saveToFileButton = Gtk::make_managed<Gtk::Button>();
saveToFileButton->set_child(*saveToFileLabel);
auto saveToFileButton = Gtk::make_managed<IconButton>(Icon::SAVE);
saveToFileButton->signal_clicked().connect([this]() {
// xdg-pic/screenshot // use env
auto xdgPicturesDir = Glib::get_user_special_dir(Glib::UserDirectory::PICTURES);
auto dateStamp = Glib::DateTime::create_now_local().format("%Y%m%d_%H%M%S");
auto filepath = xdgPicturesDir + "/screenshot";
@@ -112,7 +107,7 @@ void CopyNotification::createImageNotification(NotifyMessage notify) {
saveImageToFile(this->copiedImage, filepath, filename);
spdlog::info("Saved image to {}", filepath.c_str());
this->signal_close.emit(this->notificationId);
this->getSignalClose().emit(this->getNotificationId());
});
saveToFileButton->set_tooltip_text("Save to File");
saveToFileButton->add_css_class("notification-button");
@@ -123,7 +118,6 @@ void CopyNotification::createImageNotification(NotifyMessage notify) {
contentBox->append(*buttonBox);
this->mainBox.append(*contentBox);
}
void CopyNotification::createTextNotification(NotifyMessage notify) {
@@ -136,12 +130,10 @@ void CopyNotification::createTextNotification(NotifyMessage notify) {
textLabel->set_margin_bottom(10);
contentBox->append(*textLabel);
auto copyToClipboardButton = Gtk::make_managed<Gtk::Button>();
auto copyToClipboardLabel = Gtk::make_managed<Gtk::Label>("\uF0EA"); // content copy icon
copyToClipboardButton->set_child(*copyToClipboardLabel);
auto copyToClipboardButton = Gtk::make_managed<IconButton>(Icon::CONTENT_COPY);
copyToClipboardButton->signal_clicked().connect([this]() {
copyToClipboard(this->copiedText);
this->signal_close.emit(this->notificationId);
this->getSignalClose().emit(this->getNotificationId());
});
copyToClipboardButton->set_tooltip_text("Copy to Clipboard");
copyToClipboardButton->add_css_class("notification-icon-button");

View File

@@ -1,18 +1,18 @@
#include "widgets/notification/notificationWindow.hpp"
#include <cstdint>
#include <sys/types.h>
#include "components/button/textButton.hpp"
#include "helpers/string.hpp"
#include "gtkmm/box.h"
#include "gtkmm/button.h"
#include "gtkmm/gestureclick.h"
#include "gtkmm/image.h"
#include "gtkmm/label.h"
NotificationWindow::NotificationWindow(uint64_t notificationId, std::shared_ptr<Gdk::Monitor> monitor, NotifyMessage notify) : BaseNotification(notificationId, monitor) {
set_title(notify.summary);
// Main vertical box
auto vbox = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 8);
vbox->set_halign(Gtk::Align::FILL);
@@ -71,8 +71,7 @@ NotificationWindow::NotificationWindow(uint64_t notificationId, std::shared_ptr<
std::string action_id = notify.actions[i];
std::string action_label = notify.actions[i + 1];
auto btn = Gtk::make_managed<Gtk::Button>();
btn->set_label(action_label);
auto btn = Gtk::make_managed<TextButton>(action_label);
btn->add_css_class("notification-button");
@@ -92,7 +91,7 @@ NotificationWindow::NotificationWindow(uint64_t notificationId, std::shared_ptr<
if (cb && guard && !*guard) {
*guard = true;
cb(action_id);
this->signal_close.emit(this->notificationId);
this->getSignalClose().emit(this->getNotificationId());
}
});
actions_box->append(*btn);

View File

@@ -1,6 +1,8 @@
#include "widgets/notification/spotifyNotification.hpp"
#include <sys/types.h>
#include "components/button/iconButton.hpp"
#include "helpers/string.hpp"
#include "services/textureCache.hpp"
@@ -58,17 +60,17 @@ std::unique_ptr<Gtk::CenterBox> SpotifyNotification::createButtonBox(MprisPlayer
buttonBox->set_hexpand(true);
buttonBox->set_halign(Gtk::Align::CENTER);
auto backButton = Gtk::make_managed<Gtk::Button>("\ue045");
auto backButton = Gtk::make_managed<IconButton>(Icon::SKIP_PREVIOUS);
backButton->add_css_class("notification-icon-button");
backButton->add_css_class("notification-button");
backButton->signal_clicked().connect([this, mpris]() {
if (mpris.previous) {
mpris.previous();
this->signal_close.emit(this->notificationId);
this->getSignalClose().emit(this->getNotificationId());
}
});
auto playPauseButton = Gtk::make_managed<Gtk::Button>("\ue037");
auto playPauseButton = Gtk::make_managed<IconButton>(Icon::PLAY_ARROW);
playPauseButton->add_css_class("notification-icon-button");
playPauseButton->add_css_class("notification-button");
playPauseButton->signal_clicked().connect([playPauseButton, mpris]() {
@@ -77,21 +79,21 @@ std::unique_ptr<Gtk::CenterBox> SpotifyNotification::createButtonBox(MprisPlayer
static bool isPlaying = false;
if (isPlaying) {
playPauseButton->set_label("\ue037");
playPauseButton->setIcon(Icon::PLAY_ARROW);
} else {
playPauseButton->set_label("\ue034");
playPauseButton->setIcon(Icon::PAUSE);
}
isPlaying = !isPlaying;
}
});
auto nextButton = Gtk::make_managed<Gtk::Button>("\ue044");
auto nextButton = Gtk::make_managed<IconButton>(Icon::SKIP_NEXT);
nextButton->add_css_class("notification-icon-button");
nextButton->add_css_class("notification-button");
nextButton->signal_clicked().connect([this, mpris]() {
if (mpris.next) {
mpris.next();
this->signal_close.emit(this->notificationId);
this->getSignalClose().emit(this->getNotificationId());
}
});
buttonBox->set_start_widget(*backButton);

View File

@@ -1,13 +1,12 @@
#include "widgets/tray.hpp"
#include <cmath>
#include <gdkmm/rectangle.h>
#include <gio/gmenu.h>
#include <gtk/gtk.h>
#include <cmath>
#include <graphene.h>
#include <utility>
#include <gtk/gtk.h>
#include <spdlog/spdlog.h>
#include "components/base/button.hpp"
#include <utility>
namespace {
bool is_wayland_display(GtkWidget *widget) {
@@ -182,8 +181,7 @@ void log_menu_tree(const std::vector<TrayService::MenuNode> &nodes,
}
} // namespace
TrayIconWidget::TrayIconWidget( std::string id)
: Button(id), id(std::move(id)),
TrayIconWidget::TrayIconWidget(Icon::Type icon, std::string id) : IconButton(icon), id(std::move(id)),
container(Gtk::Orientation::HORIZONTAL) {
aliveFlag = std::make_shared<bool>(true);
set_has_frame(false);
@@ -592,7 +590,7 @@ void TrayWidget::on_item_added(const TrayService::Item &item) {
return;
}
auto icon = std::make_unique<TrayIconWidget>(item.id);
auto icon = std::make_unique<TrayIconWidget>(Icon::Type::CONTENT_COPY, item.id);
icon->update(item);
auto *raw = icon.get();
append(*raw);

View File

@@ -1,9 +1,9 @@
#include "widgets/volumeWidget.hpp"
#include <cmath>
#include <spdlog/spdlog.h>
#include <regex>
#include <sigc++/functors/mem_fun.h>
#include <spdlog/spdlog.h>
#include "helpers/command.hpp"

View File

@@ -3,7 +3,9 @@
#include <gtkmm/label.h>
#include <webkit/webkit.h>
WebWidget::WebWidget(std::string icon, std::string name, std::string url) : Popover(icon, name) {
#include "components/button/iconButton.hpp"
WebWidget::WebWidget(Icon::Type icon, std::string name, std::string url) : Popover(icon, name) {
auto webview = webkit_web_view_new();
gtk_widget_set_hexpand(webview, true);
gtk_widget_set_vexpand(webview, true);

View File

@@ -1,580 +0,0 @@
{
"latitude": 49.0,
"longitude": 8.4,
"generationtime_ms": 0.23317337036132812,
"utc_offset_seconds": 3600,
"timezone": "Europe/Berlin",
"timezone_abbreviation": "GMT+1",
"elevation": 122.0,
"current_units": {
"time": "iso8601",
"interval": "seconds",
"temperature_2m": "°C"
},
"current": {
"time": "2026-02-03T23:00",
"interval": 900,
"temperature_2m": -0.7
},
"hourly_units": {
"time": "iso8601",
"temperature_2m": "°C",
"rain": "mm"
},
"hourly": {
"time": [
"2026-02-03T00:00",
"2026-02-03T01:00",
"2026-02-03T02:00",
"2026-02-03T03:00",
"2026-02-03T04:00",
"2026-02-03T05:00",
"2026-02-03T06:00",
"2026-02-03T07:00",
"2026-02-03T08:00",
"2026-02-03T09:00",
"2026-02-03T10:00",
"2026-02-03T11:00",
"2026-02-03T12:00",
"2026-02-03T13:00",
"2026-02-03T14:00",
"2026-02-03T15:00",
"2026-02-03T16:00",
"2026-02-03T17:00",
"2026-02-03T18:00",
"2026-02-03T19:00",
"2026-02-03T20:00",
"2026-02-03T21:00",
"2026-02-03T22:00",
"2026-02-03T23:00",
"2026-02-04T00:00",
"2026-02-04T01:00",
"2026-02-04T02:00",
"2026-02-04T03:00",
"2026-02-04T04:00",
"2026-02-04T05:00",
"2026-02-04T06:00",
"2026-02-04T07:00",
"2026-02-04T08:00",
"2026-02-04T09:00",
"2026-02-04T10:00",
"2026-02-04T11:00",
"2026-02-04T12:00",
"2026-02-04T13:00",
"2026-02-04T14:00",
"2026-02-04T15:00",
"2026-02-04T16:00",
"2026-02-04T17:00",
"2026-02-04T18:00",
"2026-02-04T19:00",
"2026-02-04T20:00",
"2026-02-04T21:00",
"2026-02-04T22:00",
"2026-02-04T23:00",
"2026-02-05T00:00",
"2026-02-05T01:00",
"2026-02-05T02:00",
"2026-02-05T03:00",
"2026-02-05T04:00",
"2026-02-05T05:00",
"2026-02-05T06:00",
"2026-02-05T07:00",
"2026-02-05T08:00",
"2026-02-05T09:00",
"2026-02-05T10:00",
"2026-02-05T11:00",
"2026-02-05T12:00",
"2026-02-05T13:00",
"2026-02-05T14:00",
"2026-02-05T15:00",
"2026-02-05T16:00",
"2026-02-05T17:00",
"2026-02-05T18:00",
"2026-02-05T19:00",
"2026-02-05T20:00",
"2026-02-05T21:00",
"2026-02-05T22:00",
"2026-02-05T23:00",
"2026-02-06T00:00",
"2026-02-06T01:00",
"2026-02-06T02:00",
"2026-02-06T03:00",
"2026-02-06T04:00",
"2026-02-06T05:00",
"2026-02-06T06:00",
"2026-02-06T07:00",
"2026-02-06T08:00",
"2026-02-06T09:00",
"2026-02-06T10:00",
"2026-02-06T11:00",
"2026-02-06T12:00",
"2026-02-06T13:00",
"2026-02-06T14:00",
"2026-02-06T15:00",
"2026-02-06T16:00",
"2026-02-06T17:00",
"2026-02-06T18:00",
"2026-02-06T19:00",
"2026-02-06T20:00",
"2026-02-06T21:00",
"2026-02-06T22:00",
"2026-02-06T23:00",
"2026-02-07T00:00",
"2026-02-07T01:00",
"2026-02-07T02:00",
"2026-02-07T03:00",
"2026-02-07T04:00",
"2026-02-07T05:00",
"2026-02-07T06:00",
"2026-02-07T07:00",
"2026-02-07T08:00",
"2026-02-07T09:00",
"2026-02-07T10:00",
"2026-02-07T11:00",
"2026-02-07T12:00",
"2026-02-07T13:00",
"2026-02-07T14:00",
"2026-02-07T15:00",
"2026-02-07T16:00",
"2026-02-07T17:00",
"2026-02-07T18:00",
"2026-02-07T19:00",
"2026-02-07T20:00",
"2026-02-07T21:00",
"2026-02-07T22:00",
"2026-02-07T23:00",
"2026-02-08T00:00",
"2026-02-08T01:00",
"2026-02-08T02:00",
"2026-02-08T03:00",
"2026-02-08T04:00",
"2026-02-08T05:00",
"2026-02-08T06:00",
"2026-02-08T07:00",
"2026-02-08T08:00",
"2026-02-08T09:00",
"2026-02-08T10:00",
"2026-02-08T11:00",
"2026-02-08T12:00",
"2026-02-08T13:00",
"2026-02-08T14:00",
"2026-02-08T15:00",
"2026-02-08T16:00",
"2026-02-08T17:00",
"2026-02-08T18:00",
"2026-02-08T19:00",
"2026-02-08T20:00",
"2026-02-08T21:00",
"2026-02-08T22:00",
"2026-02-08T23:00",
"2026-02-09T00:00",
"2026-02-09T01:00",
"2026-02-09T02:00",
"2026-02-09T03:00",
"2026-02-09T04:00",
"2026-02-09T05:00",
"2026-02-09T06:00",
"2026-02-09T07:00",
"2026-02-09T08:00",
"2026-02-09T09:00",
"2026-02-09T10:00",
"2026-02-09T11:00",
"2026-02-09T12:00",
"2026-02-09T13:00",
"2026-02-09T14:00",
"2026-02-09T15:00",
"2026-02-09T16:00",
"2026-02-09T17:00",
"2026-02-09T18:00",
"2026-02-09T19:00",
"2026-02-09T20:00",
"2026-02-09T21:00",
"2026-02-09T22:00",
"2026-02-09T23:00"
],
"temperature_2m": [
2.2,
2.2,
2.2,
2.2,
2.0,
1.9,
1.8,
1.5,
1.2,
1.4,
1.8,
2.2,
2.5,
1.9,
2.6,
3.0,
2.7,
3.0,
3.0,
2.4,
1.7,
1.3,
0.9,
-0.7,
-0.2,
-0.1,
-0.5,
-0.7,
-1.4,
-1.1,
-1.0,
-1.0,
-1.1,
-0.9,
1.7,
3.7,
5.0,
5.8,
6.5,
6.9,
6.6,
5.9,
4.8,
3.6,
2.7,
2.0,
1.5,
1.1,
0.5,
0.2,
0.4,
0.9,
1.2,
1.3,
1.5,
1.7,
1.8,
2.0,
2.2,
2.7,
3.4,
4.2,
5.2,
6.1,
6.4,
5.9,
4.5,
3.2,
2.4,
1.9,
1.4,
1.1,
1.0,
0.8,
0.5,
0.3,
0.1,
-0.1,
-0.2,
-0.3,
-0.3,
-0.1,
0.7,
1.7,
2.9,
4.1,
5.0,
5.2,
5.1,
4.8,
4.3,
4.1,
4.2,
4.1,
3.8,
3.5,
3.3,
3.4,
3.4,
3.5,
3.5,
3.5,
3.4,
3.4,
3.5,
3.6,
4.1,
5.2,
6.6,
7.8,
8.4,
8.8,
8.8,
8.1,
6.9,
5.9,
5.3,
4.9,
4.6,
4.3,
4.2,
4.0,
3.9,
3.9,
3.8,
3.8,
3.8,
3.9,
4.3,
4.7,
5.3,
6.0,
6.9,
7.5,
7.6,
7.5,
7.2,
6.6,
5.8,
5.0,
4.4,
3.9,
3.5,
3.1,
2.9,
2.8,
3.0,
3.3,
3.6,
3.5,
3.4,
3.4,
3.7,
4.2,
4.7,
5.3,
6.0,
6.5,
6.8,
6.8,
6.6,
5.9,
4.8,
3.9,
3.5,
3.3,
3.1,
2.9
],
"rain": [
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.10,
0.40,
0.00,
0.00,
0.20,
0.60,
0.30,
1.30,
0.00,
0.00,
0.40,
0.10,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.10,
0.20,
0.00,
0.00,
0.00,
0.10,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00
]
},
"daily_units": {
"time": "iso8601",
"temperature_2m_max": "°C",
"temperature_2m_min": "°C",
"weather_code": "wmo code"
},
"daily": {
"time": [
"2026-02-03",
"2026-02-04",
"2026-02-05",
"2026-02-06",
"2026-02-07",
"2026-02-08",
"2026-02-09"
],
"temperature_2m_max": [
3.0,
6.9,
6.4,
5.2,
8.8,
7.6,
6.8
],
"temperature_2m_min": [
-0.7,
-1.4,
0.2,
-0.3,
3.3,
3.1,
2.8
],
"weather_code": [
61,
45,
45,
61,
61,
3,
3
]
}
}