polybar-dwm/include/modules/script.hpp
Michael Carlberg 946843ff59 feat(script): Configurable condition using exec-if
Add new config parameter `exec-if = cmd` that needs to
exit successfully before the main exec command will be invoked.

Closes #298
2017-01-10 03:02:00 +01:00

51 lines
1.0 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);
virtual ~script_module() {}
virtual void start();
virtual void stop();
string get_output();
bool build(builder* builder, const string& tag) const;
protected:
virtual void process() = 0;
virtual chrono::duration<double> sleep_duration() = 0;
static constexpr const char* TAG_OUTPUT{"<output>"};
static constexpr const char* TAG_LABEL{"<label>"};
unique_ptr<command> m_command;
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};
// @deprecated
size_t m_maxlen{0};
// @deprecated
bool m_ellipsis{true};
bool m_stopping{false};
};
}
POLYBAR_NS_END