waybar/include/modules/custom.hpp

39 lines
819 B
C++
Raw Normal View History

#pragma once
#include <fmt/format.h>
2018-08-18 17:27:40 +02:00
#include <iostream>
2019-03-18 18:46:44 +01:00
#include <csignal>
2018-12-26 11:13:36 +01:00
#include "util/sleeper_thread.hpp"
#include "util/command.hpp"
#include "util/json.hpp"
#include "ALabel.hpp"
namespace waybar::modules {
class Custom : public ALabel {
2018-08-16 14:29:41 +02:00
public:
2018-12-18 17:30:54 +01:00
Custom(const std::string&, const Json::Value&);
2018-12-08 12:58:47 +01:00
~Custom();
2018-08-16 14:29:41 +02:00
auto update() -> void;
2019-03-18 18:46:44 +01:00
void refresh(int /*signal*/);
2018-08-16 14:29:41 +02:00
private:
2018-09-18 23:15:37 +02:00
void delayWorker();
void continuousWorker();
void parseOutputRaw();
void parseOutputJson();
2018-08-20 14:50:45 +02:00
const std::string name_;
std::string text_;
std::string alt_;
std::string tooltip_;
std::string class_;
std::string prevclass_;
int percentage_;
2018-08-16 14:29:41 +02:00
waybar::util::SleeperThread thread_;
waybar::util::command::res output_;
waybar::util::JsonParser parser_;
2018-12-08 12:58:47 +01:00
FILE* fp_;
2018-08-16 14:29:41 +02:00
};
}