2022-03-15 16:54:06 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <libupower-glib/upower.h>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <iostream>
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "ALabel.hpp"
|
|
|
|
#include "gtkmm/box.h"
|
|
|
|
#include "gtkmm/image.h"
|
|
|
|
#include "gtkmm/label.h"
|
|
|
|
|
|
|
|
namespace waybar::modules {
|
|
|
|
|
|
|
|
class UPower : public AModule {
|
|
|
|
public:
|
|
|
|
UPower(const std::string &, const Json::Value &);
|
|
|
|
~UPower();
|
|
|
|
auto update() -> void;
|
|
|
|
|
|
|
|
private:
|
|
|
|
static void deviceAdded_cb(UpClient *client, UpDevice *device, gpointer data);
|
|
|
|
static void deviceRemoved_cb(UpClient *client, const gchar *object_path, gpointer data);
|
|
|
|
static void deviceNotify_cb(gpointer data);
|
2022-03-15 21:49:40 +00:00
|
|
|
static void prepareForSleep_cb(GDBusConnection *system_bus, const gchar *sender_name,
|
|
|
|
const gchar *object_path, const gchar *interface_name,
|
|
|
|
const gchar *signal_name, GVariant *parameters,
|
|
|
|
gpointer user_data);
|
2022-03-15 16:54:06 +00:00
|
|
|
void removeDevice(const std::string devicePath);
|
|
|
|
void addDevice(UpDevice *device);
|
|
|
|
void setDisplayDevice();
|
|
|
|
void resetDevices();
|
|
|
|
|
|
|
|
Gtk::Box box_;
|
|
|
|
Gtk::Image icon_;
|
|
|
|
Gtk::Label label_;
|
|
|
|
|
2022-03-15 19:22:04 +00:00
|
|
|
// Config
|
|
|
|
bool hideIfEmpty = true;
|
|
|
|
uint iconSize = 32;
|
|
|
|
|
2022-03-15 16:54:06 +00:00
|
|
|
UpClient *client = NULL;
|
|
|
|
UpDevice *displayDevice = NULL;
|
|
|
|
std::map<std::string, UpDevice *> devices;
|
2022-03-15 21:49:40 +00:00
|
|
|
guint login1_id;
|
|
|
|
GDBusConnection *login1_connection;
|
2022-03-15 16:54:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace waybar::modules
|