1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00
polybar/include/modules/temperature.hpp
Quan 39c73a8234
feat: Warn state for cpu, memory, fs, battery modules (#2199)
* [Temperature, Ramp] fix wrong icon for temperatures near base and warn temps

* [Temperature, Ramp] fix wrong icon for temperatures near base and warn temps

* Fix minor error

* Added WARN state for cpu module

* Implement WARN state for CPU, Memory modules, working on fs module

* Implement WARN state for fs module

* Simplify WARN state implementation for cpu and memory

* explicitly check percentage in get_by_percentage_with_borders

* Fixed silly error

* implement warn state on battery module, standardize the implementation on other modules

* minor fixes

* fix annoying error

* use more intuitive param name

* Fix percentage with borders bug

* Make requested changes
Hide the effect of warn states when unused

* Backward Compat: use no format instead of fallback label

* Reformat

* Refactor

* Reformat

* Reformat: convert tabs to spaces

* Reformat
2020-12-02 15:55:13 +01:00

44 lines
1 KiB
C++

#pragma once
#include <istream>
#include "modules/meta/timer_module.hpp"
#include "settings.hpp"
POLYBAR_NS
namespace modules {
enum class temp_state { NORMAL = 0, WARN };
class temperature_module : public timer_module<temperature_module> {
public:
explicit temperature_module(const bar_settings&, string);
bool update();
string get_format() const;
bool build(builder* builder, const string& tag) const;
static constexpr auto TYPE = "internal/temperature";
private:
static constexpr auto TAG_LABEL = "<label>";
static constexpr auto TAG_LABEL_WARN = "<label-warn>";
static constexpr auto TAG_RAMP = "<ramp>";
static constexpr auto FORMAT_WARN = "format-warn";
map<temp_state, label_t> m_label;
ramp_t m_ramp;
string m_path;
int m_zone = 0;
// Base temperature used for where to start the ramp
int m_tempbase = 0;
int m_tempwarn = 0;
int m_temp = 0;
// Whether or not to show units with the %temperature-X% tokens
bool m_units{true};
};
} // namespace modules
POLYBAR_NS_END