1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00
polybar/include/modules/script.hpp
Patrick Ziegler d5be8cad97
Add compiler warning for missing override specifier (#2341)
* build: Add -Wsuggest-override

We should always use the override specifier when overriding virtual
functions. This helps prevent errors when a subclass tries to create a
function with the same name as a virtual function in a super-class but
with a different purpose.

* clang-format

* Upload logs on failure

* Add override to unsupported.hpp

* cmake: Make -Wsuggest-override flag conditional
2021-01-04 10:38:43 +01:00

51 lines
1.1 KiB
C++

#pragma once
#include "modules/meta/base.hpp"
#include "utils/command.hpp"
#include "utils/io.hpp"
POLYBAR_NS
namespace modules {
class script_module : public module<script_module> {
public:
explicit script_module(const bar_settings&, string);
~script_module() {}
void start() override;
void stop() override;
string get_output();
bool build(builder* builder, const string& tag) const;
static constexpr auto TYPE = "custom/script";
protected:
chrono::duration<double> process(const mutex_wrapper<function<chrono::duration<double>()>>& handler) const;
bool check_condition();
private:
static constexpr const char* TAG_LABEL{"<label>"};
mutex_wrapper<function<chrono::duration<double>()>> m_handler;
unique_ptr<command<output_policy::REDIRECTED>> m_command;
bool m_tail;
string m_exec;
string m_exec_if;
chrono::duration<double> m_interval{0};
map<mousebtn, string> m_actions;
label_t m_label;
string m_output;
string m_prev;
int m_counter{0};
bool m_stopping{false};
};
} // namespace modules
POLYBAR_NS_END