2016-05-31 03:58:58 +00:00
|
|
|
#pragma once
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2021-10-02 23:27:11 +00:00
|
|
|
#include "adapters/script_runner.hpp"
|
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:
|
2023-05-01 12:58:52 +00:00
|
|
|
explicit script_module(const bar_settings&, string, const config&);
|
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();
|
2022-02-23 14:01:28 +00:00
|
|
|
string get_format() const;
|
|
|
|
|
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
|
|
|
bool check_condition();
|
2017-01-01 07:58:33 +00:00
|
|
|
|
2017-01-10 04:12:53 +00:00
|
|
|
private:
|
2022-04-03 11:11:13 +00:00
|
|
|
void handle_runner_update(const script_runner::data&);
|
|
|
|
|
2022-02-23 14:01:28 +00:00
|
|
|
static constexpr auto TAG_LABEL = "<label>";
|
|
|
|
static constexpr auto TAG_LABEL_FAIL = "<label-fail>";
|
|
|
|
static constexpr auto FORMAT_FAIL = "format-fail";
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2021-10-02 23:27:11 +00:00
|
|
|
const bool m_tail;
|
2022-03-06 08:34:12 +00:00
|
|
|
const script_runner::interval m_interval_success{0};
|
|
|
|
const script_runner::interval m_interval_fail{0};
|
|
|
|
const script_runner::interval m_interval_if{0};
|
2017-01-10 04:12:53 +00:00
|
|
|
|
2021-10-02 23:27:11 +00:00
|
|
|
script_runner m_runner;
|
2016-06-15 03:32:35 +00:00
|
|
|
|
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;
|
2022-02-23 14:01:28 +00:00
|
|
|
label_t m_label_fail;
|
2022-04-03 11:11:13 +00:00
|
|
|
|
|
|
|
int m_exit_status{0};
|
|
|
|
script_runner::data m_data;
|
|
|
|
std::mutex m_data_mutex;
|
2016-05-19 14:41:06 +00:00
|
|
|
};
|
2022-04-03 11:11:13 +00:00
|
|
|
} // namespace modules
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS_END
|