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