2016-05-30 23:58:58 -04:00
|
|
|
#pragma once
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2017-01-01 02:58:33 -05:00
|
|
|
#include "modules/meta/base.hpp"
|
2016-06-14 23:32:35 -04:00
|
|
|
#include "utils/command.hpp"
|
2017-01-01 02:58:33 -05:00
|
|
|
#include "utils/io.hpp"
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
namespace modules {
|
2017-01-01 02:58:33 -05:00
|
|
|
class script_module : public module<script_module> {
|
2016-06-14 23:32:35 -04:00
|
|
|
public:
|
2016-12-21 02:00:09 -05:00
|
|
|
explicit script_module(const bar_settings&, string);
|
2017-01-09 23:12:53 -05:00
|
|
|
~script_module() {}
|
2017-01-01 02:58:33 -05:00
|
|
|
|
2017-01-09 23:12:53 -05:00
|
|
|
void start();
|
|
|
|
void stop();
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2016-11-02 15:22:45 -04:00
|
|
|
string get_output();
|
2016-11-25 07:55:15 -05:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
protected:
|
2017-01-09 23:12:53 -05:00
|
|
|
chrono::duration<double> process(const mutex_wrapper<function<chrono::duration<double>()>>& handler) const;
|
|
|
|
bool check_condition();
|
2017-01-01 02:58:33 -05:00
|
|
|
|
2017-01-09 23:12:53 -05:00
|
|
|
private:
|
2016-12-03 15:07:40 -05:00
|
|
|
static constexpr const char* TAG_LABEL{"<label>"};
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2017-01-09 23:12:53 -05:00
|
|
|
mutex_wrapper<function<chrono::duration<double>()>> m_handler;
|
|
|
|
|
2016-12-05 14:41:00 -05:00
|
|
|
unique_ptr<command> m_command;
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2018-01-02 07:52:34 -05:00
|
|
|
bool m_tail;
|
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
string m_exec;
|
2017-01-09 21:01:59 -05:00
|
|
|
string m_exec_if;
|
|
|
|
|
2016-11-20 17:04:31 -05:00
|
|
|
chrono::duration<double> m_interval{0};
|
2016-10-15 07:15:56 -04:00
|
|
|
map<mousebtn, string> m_actions;
|
2016-10-14 11:18:29 -04:00
|
|
|
|
2016-12-03 15:07:40 -05:00
|
|
|
label_t m_label;
|
2016-10-15 07:15:56 -04:00
|
|
|
string m_output;
|
|
|
|
string m_prev;
|
|
|
|
int m_counter{0};
|
2016-12-03 15:07:40 -05:00
|
|
|
|
2017-01-01 02:58:33 -05:00
|
|
|
bool m_stopping{false};
|
2016-05-19 10:41:06 -04:00
|
|
|
};
|
|
|
|
}
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS_END
|