2024-02-26 13:40:28 +00:00
|
|
|
#pragma once
|
2024-02-18 21:06:21 +00:00
|
|
|
|
|
|
|
#include <fmt/format.h>
|
|
|
|
|
|
|
|
#include "ALabel.hpp"
|
|
|
|
#include "giomm/dbusproxy.h"
|
|
|
|
|
|
|
|
namespace waybar::modules {
|
|
|
|
|
2024-02-26 14:07:21 +00:00
|
|
|
struct Profile {
|
2024-02-18 21:06:21 +00:00
|
|
|
std::string name;
|
|
|
|
std::string driver;
|
2024-02-26 14:07:21 +00:00
|
|
|
};
|
2024-02-18 21:06:21 +00:00
|
|
|
|
2024-02-26 13:40:28 +00:00
|
|
|
class PowerProfilesDaemon : public ALabel {
|
2024-02-18 21:06:21 +00:00
|
|
|
public:
|
2024-03-01 11:33:36 +00:00
|
|
|
PowerProfilesDaemon(const std::string &, const Json::Value &);
|
2024-02-18 21:06:21 +00:00
|
|
|
auto update() -> void override;
|
2024-03-01 11:33:36 +00: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 21:06:21 +00:00
|
|
|
void populateInitState();
|
2024-03-01 11:33:36 +00:00
|
|
|
bool handleToggle(GdkEventButton *const &e) override;
|
2024-02-26 13:40:28 +00:00
|
|
|
|
2024-02-18 21:06:21 +00:00
|
|
|
private:
|
2024-03-01 11:33:36 +00:00
|
|
|
// True if we're connected to the dbug interface. False if we're
|
|
|
|
// not.
|
|
|
|
bool connected_;
|
2024-02-18 21:06:21 +00:00
|
|
|
// Look for a profile name in the list of available profiles and
|
|
|
|
// switch activeProfile_ to it.
|
2024-03-01 11:33:36 +00:00
|
|
|
void switchToProfile(std::string const &);
|
2024-02-18 21:06:21 +00: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_;
|
2024-03-01 18:37:20 +00:00
|
|
|
// Format string
|
2024-03-01 10:13:57 +00:00
|
|
|
std::string tooltipFormat_;
|
2024-02-18 21:06:21 +00:00
|
|
|
// DBus Proxy used to track the current active profile
|
2024-02-26 14:07:21 +00:00
|
|
|
Glib::RefPtr<Gio::DBus::Proxy> powerProfilesProxy_;
|
2024-02-18 21:06:21 +00:00
|
|
|
};
|
|
|
|
|
2024-02-26 13:40:28 +00:00
|
|
|
} // namespace waybar::modules
|