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