|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include <fmt/format.h> |
| 4 | + |
| 5 | +#include "ALabel.hpp" |
| 6 | +#include "giomm/dbusproxy.h" |
| 7 | + |
| 8 | +namespace waybar::modules { |
| 9 | + |
| 10 | +struct Profile { |
| 11 | + std::string name; |
| 12 | + std::string driver; |
| 13 | +}; |
| 14 | + |
| 15 | +class PowerProfilesDaemon : public ALabel { |
| 16 | + public: |
| 17 | + PowerProfilesDaemon(const std::string &, const Json::Value &); |
| 18 | + auto update() -> void override; |
| 19 | + void profileChangedCb(const Gio::DBus::Proxy::MapChangedProperties &, |
| 20 | + const std::vector<Glib::ustring> &); |
| 21 | + void busConnectedCb(Glib::RefPtr<Gio::AsyncResult> &r); |
| 22 | + void getAllPropsCb(Glib::RefPtr<Gio::AsyncResult> &r); |
| 23 | + void setPropCb(Glib::RefPtr<Gio::AsyncResult> &r); |
| 24 | + void populateInitState(); |
| 25 | + bool handleToggle(GdkEventButton *const &e) override; |
| 26 | + |
| 27 | + private: |
| 28 | + // True if we're connected to the dbug interface. False if we're |
| 29 | + // not. |
| 30 | + bool connected_; |
| 31 | + // Look for a profile name in the list of available profiles and |
| 32 | + // switch activeProfile_ to it. |
| 33 | + void switchToProfile(std::string const &); |
| 34 | + // Used to toggle/display the profiles |
| 35 | + std::vector<Profile> availableProfiles_; |
| 36 | + // Points to the active profile in the profiles list |
| 37 | + std::vector<Profile>::iterator activeProfile_; |
| 38 | + // Current CSS class applied to the label |
| 39 | + std::string currentStyle_; |
| 40 | + // Format string |
| 41 | + std::string tooltipFormat_; |
| 42 | + // DBus Proxy used to track the current active profile |
| 43 | + Glib::RefPtr<Gio::DBus::Proxy> powerProfilesProxy_; |
| 44 | +}; |
| 45 | + |
| 46 | +} // namespace waybar::modules |
0 commit comments