Files

49 lines
1.5 KiB
C++
Raw Permalink Normal View History

#pragma once
2024-02-18 22:06:21 +01:00
#include <fmt/format.h>
#include "ALabel.hpp"
#include "giomm/dbusproxy.h"
namespace waybar::modules {
struct Profile {
2024-02-18 22:06:21 +01:00
std::string name;
std::string driver;
2024-06-21 15:30:12 +02:00
2024-06-21 16:43:21 +02:00
Profile(std::string n, std::string d) : name(std::move(n)), driver(std::move(d)) {}
};
2024-02-18 22:06:21 +01:00
class PowerProfilesDaemon : public ALabel {
2024-02-18 22:06:21 +01:00
public:
2026-02-04 09:24:14 +01:00
PowerProfilesDaemon(const std::string&, const Json::Value&);
2024-02-18 22:06:21 +01:00
auto update() -> void override;
2026-02-04 09:24:14 +01:00
void profileChangedCb(const Gio::DBus::Proxy::MapChangedProperties&,
const std::vector<Glib::ustring>&);
void busConnectedCb(Glib::RefPtr<Gio::AsyncResult>& r);
void getAllPropsCb(Glib::RefPtr<Gio::AsyncResult>& r);
void setPropCb(Glib::RefPtr<Gio::AsyncResult>& r);
2024-02-18 22:06:21 +01:00
void populateInitState();
2026-02-04 09:24:14 +01:00
bool handleToggle(GdkEventButton* const& e) override;
2024-02-18 22:06:21 +01:00
private:
// True if we're connected to the dbug interface. False if we're
// not.
bool connected_;
2024-02-18 22:06:21 +01:00
// Look for a profile name in the list of available profiles and
// switch activeProfile_ to it.
2026-02-04 09:24:14 +01:00
void switchToProfile(std::string const&);
2024-02-18 22:06:21 +01:00
// Used to toggle/display the profiles
std::vector<Profile> availableProfiles_;
// Points to the active profile in the profiles list
std::vector<Profile>::iterator activeProfile_;
// Current CSS class applied to the label
std::string currentStyle_;
// Format string
std::string tooltipFormat_;
2024-02-18 22:06:21 +01:00
// DBus Proxy used to track the current active profile
Glib::RefPtr<Gio::DBus::Proxy> powerProfilesProxy_;
2024-02-18 22:06:21 +01:00
};
} // namespace waybar::modules