polybar-dwm/include/modules/battery.hpp

63 lines
2.0 KiB
C++
Raw Normal View History

#pragma once
2016-05-19 14:41:06 +00:00
#include <memory>
#include <string>
#include "modules/base.hpp"
#include "drawtypes/animation.hpp"
#include "drawtypes/icon.hpp"
#include "drawtypes/label.hpp"
#include "drawtypes/ramp.hpp"
namespace modules
{
DefineModule(BatteryModule, InotifyModule)
{
public:
static const int STATE_UNKNOWN = 1;
static const int STATE_CHARGING = 2;
static const int STATE_DISCHARGING = 3;
static const int STATE_FULL = 4;
protected:
static constexpr auto FORMAT_CHARGING = "format-charging";
static constexpr auto FORMAT_DISCHARGING = "format-discharging";
static constexpr auto FORMAT_FULL = "format-full";
static constexpr auto TAG_ANIMATION_CHARGING = "<animation-charging>";
static constexpr auto TAG_BAR_CAPACITY = "<bar-capacity>";
static constexpr auto TAG_RAMP_CAPACITY = "<ramp-capacity>";
static constexpr auto TAG_LABEL_CHARGING = "<label-charging>";
static constexpr auto TAG_LABEL_DISCHARGING = "<label-discharging>";
static constexpr auto TAG_LABEL_FULL = "<label-full>";
std::unique_ptr<drawtypes::Animation> animation_charging;
std::unique_ptr<drawtypes::Ramp> ramp_capacity;
std::unique_ptr<drawtypes::Bar> bar_capacity;
std::unique_ptr<drawtypes::Label> label_charging;
std::unique_ptr<drawtypes::Label> label_charging_tokenized;
std::unique_ptr<drawtypes::Label> label_discharging;
std::unique_ptr<drawtypes::Label> label_discharging_tokenized;
std::unique_ptr<drawtypes::Label> label_full;
std::unique_ptr<drawtypes::Label> label_full_tokenized;
std::string battery, adapter;
2016-06-21 02:34:48 +00:00
std::string path_capacity, path_adapter;
concurrency::Atomic<int> state;
concurrency::Atomic<int> percentage;
int full_at;
void subthread_routine();
2016-05-19 14:41:06 +00:00
public:
2016-06-21 01:59:43 +00:00
explicit BatteryModule(std::string name);
2016-05-19 14:41:06 +00:00
void start();
2016-05-19 14:41:06 +00:00
bool on_event(InotifyEvent *event);
std::string get_format();
2016-06-21 01:59:43 +00:00
bool build(Builder *builder, std::string tag);
2016-05-19 14:41:06 +00:00
};
}