refactor(modules): Move setup to constructor
This commit is contained in:
parent
81e6fb062f
commit
c01f111e34
52 changed files with 100 additions and 149 deletions
|
@ -52,7 +52,7 @@ class taskqueue : non_copyable_mixin<taskqueue> {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::thread m_thread;
|
std::thread m_thread;
|
||||||
std::mutex m_lock;
|
std::mutex m_lock{};
|
||||||
std::condition_variable m_hold;
|
std::condition_variable m_hold;
|
||||||
std::atomic_bool m_active{true};
|
std::atomic_bool m_active{true};
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,8 @@ namespace modules {
|
||||||
|
|
||||||
class backlight_module : public inotify_module<backlight_module> {
|
class backlight_module : public inotify_module<backlight_module> {
|
||||||
public:
|
public:
|
||||||
using inotify_module::inotify_module;
|
explicit backlight_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
void idle();
|
void idle();
|
||||||
bool on_event(inotify_event* event);
|
bool on_event(inotify_event* event);
|
||||||
bool build(builder* builder, const string& tag) const;
|
bool build(builder* builder, const string& tag) const;
|
||||||
|
|
|
@ -25,9 +25,8 @@ namespace modules {
|
||||||
|
|
||||||
class battery_module : public inotify_module<battery_module> {
|
class battery_module : public inotify_module<battery_module> {
|
||||||
public:
|
public:
|
||||||
using inotify_module::inotify_module;
|
explicit battery_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
void start();
|
void start();
|
||||||
void teardown();
|
void teardown();
|
||||||
void idle();
|
void idle();
|
||||||
|
@ -66,7 +65,7 @@ namespace modules {
|
||||||
map<battery_value, string> m_valuepath;
|
map<battery_value, string> m_valuepath;
|
||||||
std::atomic<int> m_percentage{0};
|
std::atomic<int> m_percentage{0};
|
||||||
int m_fullat{100};
|
int m_fullat{100};
|
||||||
chrono::duration<double> m_interval;
|
chrono::duration<double> m_interval{};
|
||||||
chrono::system_clock::time_point m_lastpoll;
|
chrono::system_clock::time_point m_lastpoll;
|
||||||
string m_timeformat;
|
string m_timeformat;
|
||||||
int m_unchanged{SKIP_N_UNCHANGED};
|
int m_unchanged{SKIP_N_UNCHANGED};
|
||||||
|
|
|
@ -36,9 +36,9 @@ namespace modules {
|
||||||
bool focused{false};
|
bool focused{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
using event_module::event_module;
|
public:
|
||||||
|
explicit bspwm_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
void stop();
|
void stop();
|
||||||
bool has_event();
|
bool has_event();
|
||||||
bool update();
|
bool update();
|
||||||
|
|
|
@ -7,9 +7,8 @@ POLYBAR_NS
|
||||||
namespace modules {
|
namespace modules {
|
||||||
class counter_module : public timer_module<counter_module> {
|
class counter_module : public timer_module<counter_module> {
|
||||||
public:
|
public:
|
||||||
using timer_module::timer_module;
|
explicit counter_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
bool update();
|
bool update();
|
||||||
bool build(builder* builder, const string& tag) const;
|
bool build(builder* builder, const string& tag) const;
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,8 @@ namespace modules {
|
||||||
|
|
||||||
class cpu_module : public timer_module<cpu_module> {
|
class cpu_module : public timer_module<cpu_module> {
|
||||||
public:
|
public:
|
||||||
using timer_module::timer_module;
|
explicit cpu_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
bool update();
|
bool update();
|
||||||
bool build(builder* builder, const string& tag) const;
|
bool build(builder* builder, const string& tag) const;
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,8 @@ POLYBAR_NS
|
||||||
namespace modules {
|
namespace modules {
|
||||||
class date_module : public timer_module<date_module> {
|
class date_module : public timer_module<date_module> {
|
||||||
public:
|
public:
|
||||||
using timer_module::timer_module;
|
explicit date_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
bool update();
|
bool update();
|
||||||
bool build(builder* builder, const string& tag) const;
|
bool build(builder* builder, const string& tag) const;
|
||||||
bool handle_event(string cmd);
|
bool handle_event(string cmd);
|
||||||
|
|
|
@ -37,9 +37,8 @@ namespace modules {
|
||||||
*/
|
*/
|
||||||
class fs_module : public timer_module<fs_module> {
|
class fs_module : public timer_module<fs_module> {
|
||||||
public:
|
public:
|
||||||
using timer_module::timer_module;
|
explicit fs_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
bool update();
|
bool update();
|
||||||
string get_format() const;
|
string get_format() const;
|
||||||
string get_output();
|
string get_output();
|
||||||
|
|
|
@ -14,7 +14,6 @@ namespace modules {
|
||||||
public:
|
public:
|
||||||
explicit github_module(const bar_settings&, string);
|
explicit github_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
bool update();
|
bool update();
|
||||||
bool build(builder* builder, const string& tag) const;
|
bool build(builder* builder, const string& tag) const;
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,9 @@ namespace modules {
|
||||||
label_t label;
|
label_t label;
|
||||||
};
|
};
|
||||||
|
|
||||||
using event_module::event_module;
|
public:
|
||||||
|
explicit i3_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
void stop();
|
void stop();
|
||||||
bool has_event();
|
bool has_event();
|
||||||
bool update();
|
bool update();
|
||||||
|
|
|
@ -8,15 +8,6 @@ POLYBAR_NS
|
||||||
struct ipc_hook; // fwd
|
struct ipc_hook; // fwd
|
||||||
|
|
||||||
namespace modules {
|
namespace modules {
|
||||||
/**
|
|
||||||
* Hook structure that will be fired
|
|
||||||
* when receiving a message with specified id
|
|
||||||
*/
|
|
||||||
struct hook {
|
|
||||||
string payload;
|
|
||||||
string command;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module that allow users to configure hooks on
|
* Module that allow users to configure hooks on
|
||||||
* received ipc messages. The hook will execute the defined
|
* received ipc messages. The hook will execute the defined
|
||||||
|
@ -25,9 +16,18 @@ namespace modules {
|
||||||
*/
|
*/
|
||||||
class ipc_module : public static_module<ipc_module> {
|
class ipc_module : public static_module<ipc_module> {
|
||||||
public:
|
public:
|
||||||
using static_module::static_module;
|
/**
|
||||||
|
* Hook structure that will be fired
|
||||||
|
* when receiving a message with specified id
|
||||||
|
*/
|
||||||
|
struct hook {
|
||||||
|
string payload;
|
||||||
|
string command;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ipc_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
string get_output();
|
string get_output();
|
||||||
bool build(builder* builder, const string& tag) const;
|
bool build(builder* builder, const string& tag) const;
|
||||||
void on_message(const ipc_hook& message);
|
void on_message(const ipc_hook& message);
|
||||||
|
|
|
@ -10,9 +10,8 @@ namespace modules {
|
||||||
|
|
||||||
class memory_module : public timer_module<memory_module> {
|
class memory_module : public timer_module<memory_module> {
|
||||||
public:
|
public:
|
||||||
using timer_module::timer_module;
|
explicit memory_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
bool update();
|
bool update();
|
||||||
bool build(builder* builder, const string& tag) const;
|
bool build(builder* builder, const string& tag) const;
|
||||||
|
|
||||||
|
|
|
@ -5,20 +5,20 @@
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
namespace modules {
|
namespace modules {
|
||||||
struct menu_tree_item {
|
|
||||||
string exec;
|
|
||||||
label_t label;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct menu_tree {
|
|
||||||
vector<unique_ptr<menu_tree_item>> items;
|
|
||||||
};
|
|
||||||
|
|
||||||
class menu_module : public static_module<menu_module> {
|
class menu_module : public static_module<menu_module> {
|
||||||
public:
|
public:
|
||||||
using static_module::static_module;
|
struct menu_tree_item {
|
||||||
|
string exec;
|
||||||
|
label_t label;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct menu_tree {
|
||||||
|
vector<unique_ptr<menu_tree_item>> items;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit menu_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
bool build(builder* builder, const string& tag) const;
|
bool build(builder* builder, const string& tag) const;
|
||||||
bool handle_event(string cmd);
|
bool handle_event(string cmd);
|
||||||
bool receive_events() const;
|
bool receive_events() const;
|
||||||
|
|
|
@ -104,7 +104,6 @@ namespace modules {
|
||||||
virtual string name() const = 0;
|
virtual string name() const = 0;
|
||||||
virtual bool running() const = 0;
|
virtual bool running() const = 0;
|
||||||
|
|
||||||
virtual void setup() = 0;
|
|
||||||
virtual void start() = 0;
|
virtual void start() = 0;
|
||||||
virtual void stop() = 0;
|
virtual void stop() = 0;
|
||||||
virtual void halt(string error_message) = 0;
|
virtual void halt(string error_message) = 0;
|
||||||
|
@ -131,7 +130,6 @@ namespace modules {
|
||||||
|
|
||||||
string name() const;
|
string name() const;
|
||||||
bool running() const;
|
bool running() const;
|
||||||
void setup();
|
|
||||||
void stop();
|
void stop();
|
||||||
void halt(string error_message);
|
void halt(string error_message);
|
||||||
void teardown();
|
void teardown();
|
||||||
|
|
|
@ -50,18 +50,6 @@ namespace modules {
|
||||||
return static_cast<bool>(m_enabled);
|
return static_cast<bool>(m_enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Impl>
|
|
||||||
void module<Impl>::setup() {
|
|
||||||
m_log.trace("%s: Setup", m_name);
|
|
||||||
|
|
||||||
try {
|
|
||||||
CAST_MOD(Impl)->setup();
|
|
||||||
} catch (const std::exception& err) {
|
|
||||||
m_log.err("%s: Setup failed", m_name);
|
|
||||||
halt(err.what());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Impl>
|
template <typename Impl>
|
||||||
void module<Impl>::stop() {
|
void module<Impl>::stop() {
|
||||||
if (!running()) {
|
if (!running()) {
|
||||||
|
|
|
@ -14,9 +14,8 @@ namespace chrono = std::chrono;
|
||||||
namespace modules {
|
namespace modules {
|
||||||
class mpd_module : public event_module<mpd_module> {
|
class mpd_module : public event_module<mpd_module> {
|
||||||
public:
|
public:
|
||||||
using event_module::event_module;
|
explicit mpd_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
void teardown();
|
void teardown();
|
||||||
inline bool connected() const;
|
inline bool connected() const;
|
||||||
void idle();
|
void idle();
|
||||||
|
|
|
@ -11,9 +11,8 @@ namespace modules {
|
||||||
|
|
||||||
class network_module : public timer_module<network_module> {
|
class network_module : public timer_module<network_module> {
|
||||||
public:
|
public:
|
||||||
using timer_module::timer_module;
|
explicit network_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
void teardown();
|
void teardown();
|
||||||
bool update();
|
bool update();
|
||||||
string get_format() const;
|
string get_format() const;
|
||||||
|
|
|
@ -16,9 +16,8 @@ namespace chrono = std::chrono;
|
||||||
namespace modules {
|
namespace modules {
|
||||||
class script_module : public event_module<script_module> {
|
class script_module : public event_module<script_module> {
|
||||||
public:
|
public:
|
||||||
using event_module::event_module;
|
explicit script_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
void stop();
|
void stop();
|
||||||
void idle();
|
void idle();
|
||||||
bool has_event();
|
bool has_event();
|
||||||
|
|
|
@ -12,9 +12,8 @@ namespace modules {
|
||||||
|
|
||||||
class temperature_module : public timer_module<temperature_module> {
|
class temperature_module : public timer_module<temperature_module> {
|
||||||
public:
|
public:
|
||||||
using timer_module::timer_module;
|
explicit temperature_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
bool update();
|
bool update();
|
||||||
string get_format() const;
|
string get_format() const;
|
||||||
bool build(builder* builder, const string& tag) const;
|
bool build(builder* builder, const string& tag) const;
|
||||||
|
|
|
@ -7,9 +7,8 @@ POLYBAR_NS
|
||||||
namespace modules {
|
namespace modules {
|
||||||
class text_module : public static_module<text_module> {
|
class text_module : public static_module<text_module> {
|
||||||
public:
|
public:
|
||||||
using static_module::static_module;
|
explicit text_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
string get_format() const;
|
string get_format() const;
|
||||||
string get_output();
|
string get_output();
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,7 +33,6 @@ namespace modules {
|
||||||
bool running() const { \
|
bool running() const { \
|
||||||
return false; \
|
return false; \
|
||||||
} \
|
} \
|
||||||
void setup() {} \
|
|
||||||
void start() {} \
|
void start() {} \
|
||||||
void stop() {} \
|
void stop() {} \
|
||||||
void halt(string) {} \
|
void halt(string) {} \
|
||||||
|
|
|
@ -20,9 +20,8 @@ namespace modules {
|
||||||
|
|
||||||
class volume_module : public event_module<volume_module> {
|
class volume_module : public event_module<volume_module> {
|
||||||
public:
|
public:
|
||||||
using event_module::event_module;
|
explicit volume_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
void teardown();
|
void teardown();
|
||||||
bool has_event();
|
bool has_event();
|
||||||
bool update();
|
bool update();
|
||||||
|
|
|
@ -25,9 +25,8 @@ namespace modules {
|
||||||
*/
|
*/
|
||||||
class xbacklight_module : public static_module<xbacklight_module>, public xpp::event::sink<evt::randr_notify> {
|
class xbacklight_module : public static_module<xbacklight_module>, public xpp::event::sink<evt::randr_notify> {
|
||||||
public:
|
public:
|
||||||
explicit xbacklight_module(const bar_settings& bar, string name);
|
explicit xbacklight_module(const bar_settings& bar, string name_);
|
||||||
|
|
||||||
void setup();
|
|
||||||
void teardown();
|
void teardown();
|
||||||
void handle(const evt::randr_notify& evt);
|
void handle(const evt::randr_notify& evt);
|
||||||
void update();
|
void update();
|
||||||
|
|
|
@ -19,9 +19,8 @@ namespace modules {
|
||||||
class xkeyboard_module : public static_module<xkeyboard_module>,
|
class xkeyboard_module : public static_module<xkeyboard_module>,
|
||||||
public xpp::event::sink<evt::xkb_new_keyboard_notify, evt::xkb_state_notify, evt::xkb_indicator_state_notify> {
|
public xpp::event::sink<evt::xkb_new_keyboard_notify, evt::xkb_state_notify, evt::xkb_indicator_state_notify> {
|
||||||
public:
|
public:
|
||||||
explicit xkeyboard_module(const bar_settings& bar, string name);
|
explicit xkeyboard_module(const bar_settings& bar, string name_);
|
||||||
|
|
||||||
void setup();
|
|
||||||
void teardown();
|
void teardown();
|
||||||
void update();
|
void update();
|
||||||
bool build(builder* builder, const string& tag) const;
|
bool build(builder* builder, const string& tag) const;
|
||||||
|
|
|
@ -34,7 +34,6 @@ namespace modules {
|
||||||
public:
|
public:
|
||||||
explicit xwindow_module(const bar_settings&, string);
|
explicit xwindow_module(const bar_settings&, string);
|
||||||
|
|
||||||
void setup();
|
|
||||||
void teardown();
|
void teardown();
|
||||||
void handle(const evt::property_notify& evt);
|
void handle(const evt::property_notify& evt);
|
||||||
void update();
|
void update();
|
||||||
|
|
|
@ -49,9 +49,8 @@ namespace modules {
|
||||||
*/
|
*/
|
||||||
class xworkspaces_module : public static_module<xworkspaces_module>, public xpp::event::sink<evt::property_notify> {
|
class xworkspaces_module : public static_module<xworkspaces_module>, public xpp::event::sink<evt::property_notify> {
|
||||||
public:
|
public:
|
||||||
explicit xworkspaces_module(const bar_settings& bar, string name);
|
explicit xworkspaces_module(const bar_settings& bar, string name_);
|
||||||
|
|
||||||
void setup();
|
|
||||||
void teardown();
|
void teardown();
|
||||||
void handle(const evt::property_notify& evt);
|
void handle(const evt::property_notify& evt);
|
||||||
void update();
|
void update();
|
||||||
|
|
|
@ -71,7 +71,7 @@ class command {
|
||||||
pid_t m_forkpid{};
|
pid_t m_forkpid{};
|
||||||
int m_forkstatus{};
|
int m_forkstatus{};
|
||||||
|
|
||||||
std::mutex m_pipelock;
|
std::mutex m_pipelock{};
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace command_util {
|
namespace command_util {
|
||||||
|
|
|
@ -280,4 +280,9 @@ chrono::milliseconds config::convert(string&& value) const {
|
||||||
return chrono::milliseconds{convert<chrono::milliseconds::rep>(forward<string>(value))};
|
return chrono::milliseconds{convert<chrono::milliseconds::rep>(forward<string>(value))};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
chrono::duration<double> config::convert(string&& value) const {
|
||||||
|
return chrono::duration<double>{convert<double>(forward<string>(value))};
|
||||||
|
}
|
||||||
|
|
||||||
POLYBAR_NS_END
|
POLYBAR_NS_END
|
||||||
|
|
|
@ -103,7 +103,6 @@ controller::controller(connection& conn, signal_emitter& emitter, const logger&
|
||||||
|
|
||||||
module->set_update_cb([&] { enqueue(make_update_evt(false)); });
|
module->set_update_cb([&] { enqueue(make_update_evt(false)); });
|
||||||
module->set_stop_cb([&] { enqueue(make_check_evt()); });
|
module->set_stop_cb([&] { enqueue(make_check_evt()); });
|
||||||
module->setup();
|
|
||||||
|
|
||||||
m_modules[align].emplace_back(move(module));
|
m_modules[align].emplace_back(move(module));
|
||||||
|
|
||||||
|
|
|
@ -137,8 +137,9 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Waiting for spawned processes to end");
|
logger.info("Waiting for spawned processes to end");
|
||||||
while (process_util::notify_childprocess())
|
while (process_util::notify_childprocess()) {
|
||||||
;
|
;
|
||||||
|
}
|
||||||
|
|
||||||
if (reload) {
|
if (reload) {
|
||||||
logger.info("Re-launching application...");
|
logger.info("Re-launching application...");
|
||||||
|
|
|
@ -14,19 +14,8 @@ namespace modules {
|
||||||
template class module<backlight_module>;
|
template class module<backlight_module>;
|
||||||
template class inotify_module<backlight_module>;
|
template class inotify_module<backlight_module>;
|
||||||
|
|
||||||
void brightness_handle::filepath(const string& path) {
|
backlight_module::backlight_module(const bar_settings& bar, string name_)
|
||||||
if (!file_util::exists(path)) {
|
: inotify_module<backlight_module>(bar, move(name_)) {
|
||||||
throw module_error("The file '" + path + "' does not exist");
|
|
||||||
}
|
|
||||||
m_path = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
float brightness_handle::read() const {
|
|
||||||
return std::strtof(file_util::get_contents(m_path).c_str(), nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void backlight_module::setup() {
|
|
||||||
// Load configuration values
|
|
||||||
auto card = m_conf.get<string>(name(), "card");
|
auto card = m_conf.get<string>(name(), "card");
|
||||||
|
|
||||||
// Add formats and elements
|
// Add formats and elements
|
||||||
|
@ -50,6 +39,17 @@ namespace modules {
|
||||||
watch(string_util::replace(PATH_BACKLIGHT_VAL, "%card%", card));
|
watch(string_util::replace(PATH_BACKLIGHT_VAL, "%card%", card));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void brightness_handle::filepath(const string& path) {
|
||||||
|
if (!file_util::exists(path)) {
|
||||||
|
throw module_error("The file '" + path + "' does not exist");
|
||||||
|
}
|
||||||
|
m_path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
float brightness_handle::read() const {
|
||||||
|
return std::strtof(file_util::get_contents(m_path).c_str(), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
void backlight_module::idle() {
|
void backlight_module::idle() {
|
||||||
sleep(75ms);
|
sleep(75ms);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,8 @@ namespace modules {
|
||||||
/**
|
/**
|
||||||
* Bootstrap module by setting up required components
|
* Bootstrap module by setting up required components
|
||||||
*/
|
*/
|
||||||
void battery_module::setup() {
|
battery_module::battery_module(const bar_settings& bar, string name_)
|
||||||
|
: inotify_module<battery_module>(bar, move(name_)) {
|
||||||
auto battery = m_conf.get<string>(name(), "battery", "BAT0");
|
auto battery = m_conf.get<string>(name(), "battery", "BAT0");
|
||||||
auto adapter = m_conf.get<string>(name(), "adapter", "ADP1");
|
auto adapter = m_conf.get<string>(name(), "adapter", "ADP1");
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace modules {
|
||||||
template class module<bspwm_module>;
|
template class module<bspwm_module>;
|
||||||
template class event_module<bspwm_module>;
|
template class event_module<bspwm_module>;
|
||||||
|
|
||||||
void bspwm_module::setup() {
|
bspwm_module::bspwm_module(const bar_settings& bar, string name_) : event_module<bspwm_module>(bar, move(name_)) {
|
||||||
auto socket_path = bspwm_util::get_socket_path();
|
auto socket_path = bspwm_util::get_socket_path();
|
||||||
|
|
||||||
if (!file_util::exists(socket_path)) {
|
if (!file_util::exists(socket_path)) {
|
||||||
|
|
|
@ -9,8 +9,9 @@ namespace modules {
|
||||||
template class module<counter_module>;
|
template class module<counter_module>;
|
||||||
template class timer_module<counter_module>;
|
template class timer_module<counter_module>;
|
||||||
|
|
||||||
void counter_module::setup() {
|
counter_module::counter_module(const bar_settings& bar, string name_)
|
||||||
m_interval = chrono::duration<double>(m_conf.get<float>(name(), "interval", 1));
|
: timer_module<counter_module>(bar, move(name_)) {
|
||||||
|
m_interval = m_conf.get(name(), "interval", m_interval);
|
||||||
m_formatter->add(DEFAULT_FORMAT, TAG_COUNTER, {TAG_COUNTER});
|
m_formatter->add(DEFAULT_FORMAT, TAG_COUNTER, {TAG_COUNTER});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace modules {
|
||||||
template class module<cpu_module>;
|
template class module<cpu_module>;
|
||||||
template class timer_module<cpu_module>;
|
template class timer_module<cpu_module>;
|
||||||
|
|
||||||
void cpu_module::setup() {
|
cpu_module::cpu_module(const bar_settings& bar, string name_) : timer_module<cpu_module>(bar, move(name_)) {
|
||||||
m_interval = chrono::duration<double>(m_conf.get<float>(name(), "interval", 1));
|
m_interval = chrono::duration<double>(m_conf.get<float>(name(), "interval", 1));
|
||||||
|
|
||||||
m_formatter->add(DEFAULT_FORMAT, TAG_LABEL, {TAG_LABEL, TAG_BAR_LOAD, TAG_RAMP_LOAD, TAG_RAMP_LOAD_PER_CORE});
|
m_formatter->add(DEFAULT_FORMAT, TAG_LABEL, {TAG_LABEL, TAG_BAR_LOAD, TAG_RAMP_LOAD, TAG_RAMP_LOAD_PER_CORE});
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace modules {
|
||||||
template class module<date_module>;
|
template class module<date_module>;
|
||||||
template class timer_module<date_module>;
|
template class timer_module<date_module>;
|
||||||
|
|
||||||
void date_module::setup() {
|
date_module::date_module(const bar_settings& bar, string name_) : timer_module<date_module>(bar, move(name_)) {
|
||||||
if (!m_bar.locale.empty()) {
|
if (!m_bar.locale.empty()) {
|
||||||
setlocale(LC_TIME, m_bar.locale.c_str());
|
setlocale(LC_TIME, m_bar.locale.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace modules {
|
||||||
* Bootstrap the module by reading config values and
|
* Bootstrap the module by reading config values and
|
||||||
* setting up required components
|
* setting up required components
|
||||||
*/
|
*/
|
||||||
void fs_module::setup() {
|
fs_module::fs_module(const bar_settings& bar, string name_) : timer_module<fs_module>(bar, move(name_)) {
|
||||||
m_mountpoints = m_conf.get_list<string>(name(), "mount");
|
m_mountpoints = m_conf.get_list<string>(name(), "mount");
|
||||||
m_fixed = m_conf.get<bool>(name(), "fixed-values", m_fixed);
|
m_fixed = m_conf.get<bool>(name(), "fixed-values", m_fixed);
|
||||||
m_spacing = m_conf.get<int>(name(), "spacing", m_spacing);
|
m_spacing = m_conf.get<int>(name(), "spacing", m_spacing);
|
||||||
|
|
|
@ -13,13 +13,8 @@ namespace modules {
|
||||||
/**
|
/**
|
||||||
* Construct module
|
* Construct module
|
||||||
*/
|
*/
|
||||||
github_module::github_module(const bar_settings& bar, string name)
|
github_module::github_module(const bar_settings& bar, string name_)
|
||||||
: timer_module<github_module>(bar, name), m_http(http_util::make_downloader()) {}
|
: timer_module<github_module>(bar, move(name_)), m_http(http_util::make_downloader()) {
|
||||||
|
|
||||||
/**
|
|
||||||
* Bootstrap module
|
|
||||||
*/
|
|
||||||
void github_module::setup() {
|
|
||||||
m_accesstoken = m_conf.get<string>(name(), "token");
|
m_accesstoken = m_conf.get<string>(name(), "token");
|
||||||
m_interval = m_conf.get(name(), "interval", 60s);
|
m_interval = m_conf.get(name(), "interval", 60s);
|
||||||
m_empty_notifications = m_conf.get(name(), "empty-notifications", m_empty_notifications);
|
m_empty_notifications = m_conf.get(name(), "empty-notifications", m_empty_notifications);
|
||||||
|
|
|
@ -15,11 +15,7 @@ namespace modules {
|
||||||
template class module<i3_module>;
|
template class module<i3_module>;
|
||||||
template class event_module<i3_module>;
|
template class event_module<i3_module>;
|
||||||
|
|
||||||
i3_module::workspace::operator bool() {
|
i3_module::i3_module(const bar_settings& bar, string name_) : event_module<i3_module>(bar, move(name_)) {
|
||||||
return label && *label;
|
|
||||||
}
|
|
||||||
|
|
||||||
void i3_module::setup() {
|
|
||||||
auto socket_path = i3ipc::get_socketpath();
|
auto socket_path = i3ipc::get_socketpath();
|
||||||
|
|
||||||
if (!file_util::exists(socket_path)) {
|
if (!file_util::exists(socket_path)) {
|
||||||
|
@ -83,6 +79,10 @@ namespace modules {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i3_module::workspace::operator bool() {
|
||||||
|
return label && *label;
|
||||||
|
}
|
||||||
|
|
||||||
void i3_module::stop() {
|
void i3_module::stop() {
|
||||||
try {
|
try {
|
||||||
if (m_ipc) {
|
if (m_ipc) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace modules {
|
||||||
* Load user-defined ipc hooks and
|
* Load user-defined ipc hooks and
|
||||||
* create formatting tags
|
* create formatting tags
|
||||||
*/
|
*/
|
||||||
void ipc_module::setup() {
|
ipc_module::ipc_module(const bar_settings& bar, string name_) : static_module<ipc_module>(bar, move(name_)) {
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
|
|
||||||
for (auto&& command : m_conf.get_list<string>(name(), "hook")) {
|
for (auto&& command : m_conf.get_list<string>(name(), "hook")) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace modules {
|
||||||
template class module<memory_module>;
|
template class module<memory_module>;
|
||||||
template class timer_module<memory_module>;
|
template class timer_module<memory_module>;
|
||||||
|
|
||||||
void memory_module::setup() {
|
memory_module::memory_module(const bar_settings& bar, string name_) : timer_module<memory_module>(bar, move(name_)) {
|
||||||
m_interval = chrono::duration<double>(m_conf.get<float>(name(), "interval", 1));
|
m_interval = chrono::duration<double>(m_conf.get<float>(name(), "interval", 1));
|
||||||
|
|
||||||
m_formatter->add(DEFAULT_FORMAT, TAG_LABEL, {TAG_LABEL, TAG_BAR_USED, TAG_BAR_FREE});
|
m_formatter->add(DEFAULT_FORMAT, TAG_LABEL, {TAG_LABEL, TAG_BAR_USED, TAG_BAR_FREE});
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace modules {
|
||||||
template class module<menu_module>;
|
template class module<menu_module>;
|
||||||
template class static_module<menu_module>;
|
template class static_module<menu_module>;
|
||||||
|
|
||||||
void menu_module::setup() {
|
menu_module::menu_module(const bar_settings& bar, string name_) : static_module<menu_module>(bar, move(name_)) {
|
||||||
string default_format{TAG_LABEL_TOGGLE + string{" "} + TAG_MENU};
|
string default_format{TAG_LABEL_TOGGLE + string{" "} + TAG_MENU};
|
||||||
|
|
||||||
m_formatter->add(DEFAULT_FORMAT, default_format, {TAG_LABEL_TOGGLE, TAG_MENU});
|
m_formatter->add(DEFAULT_FORMAT, default_format, {TAG_LABEL_TOGGLE, TAG_MENU});
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace modules {
|
||||||
template class module<mpd_module>;
|
template class module<mpd_module>;
|
||||||
template class event_module<mpd_module>;
|
template class event_module<mpd_module>;
|
||||||
|
|
||||||
void mpd_module::setup() {
|
mpd_module::mpd_module(const bar_settings& bar, string name_) : event_module<mpd_module>(bar, move(name_)) {
|
||||||
m_host = m_conf.get<string>(name(), "host", m_host);
|
m_host = m_conf.get<string>(name(), "host", m_host);
|
||||||
m_port = m_conf.get<unsigned int>(name(), "port", m_port);
|
m_port = m_conf.get<unsigned int>(name(), "port", m_port);
|
||||||
m_pass = m_conf.get<string>(name(), "password", m_pass);
|
m_pass = m_conf.get<string>(name(), "password", m_pass);
|
||||||
|
|
|
@ -14,7 +14,8 @@ namespace modules {
|
||||||
template class module<network_module>;
|
template class module<network_module>;
|
||||||
template class timer_module<network_module>;
|
template class timer_module<network_module>;
|
||||||
|
|
||||||
void network_module::setup() {
|
network_module::network_module(const bar_settings& bar, string name_)
|
||||||
|
: timer_module<network_module>(bar, move(name_)) {
|
||||||
// Load configuration values
|
// Load configuration values
|
||||||
REQ_CONFIG_VALUE(name(), m_interface, "interface");
|
REQ_CONFIG_VALUE(name(), m_interface, "interface");
|
||||||
GET_CONFIG_VALUE(name(), m_ping_nth_update, "ping-interval");
|
GET_CONFIG_VALUE(name(), m_ping_nth_update, "ping-interval");
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace modules {
|
||||||
template class module<script_module>;
|
template class module<script_module>;
|
||||||
template class event_module<script_module>;
|
template class event_module<script_module>;
|
||||||
|
|
||||||
void script_module::setup() {
|
script_module::script_module(const bar_settings& bar, string name_) : event_module<script_module>(bar, move(name_)) {
|
||||||
REQ_CONFIG_VALUE(name(), m_exec, "exec");
|
REQ_CONFIG_VALUE(name(), m_exec, "exec");
|
||||||
GET_CONFIG_VALUE(name(), m_tail, "tail");
|
GET_CONFIG_VALUE(name(), m_tail, "tail");
|
||||||
GET_CONFIG_VALUE(name(), m_maxlen, "maxlen");
|
GET_CONFIG_VALUE(name(), m_maxlen, "maxlen");
|
||||||
|
|
|
@ -14,7 +14,8 @@ namespace modules {
|
||||||
template class module<temperature_module>;
|
template class module<temperature_module>;
|
||||||
template class timer_module<temperature_module>;
|
template class timer_module<temperature_module>;
|
||||||
|
|
||||||
void temperature_module::setup() {
|
temperature_module::temperature_module(const bar_settings& bar, string name_)
|
||||||
|
: timer_module<temperature_module>(bar, move(name_)) {
|
||||||
m_zone = m_conf.get<int>(name(), "thermal-zone", 0);
|
m_zone = m_conf.get<int>(name(), "thermal-zone", 0);
|
||||||
m_tempwarn = m_conf.get<int>(name(), "warn-temperature", 80);
|
m_tempwarn = m_conf.get<int>(name(), "warn-temperature", 80);
|
||||||
m_interval = chrono::duration<double>(m_conf.get<float>(name(), "interval", 1));
|
m_interval = chrono::duration<double>(m_conf.get<float>(name(), "interval", 1));
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace modules {
|
||||||
template class module<text_module>;
|
template class module<text_module>;
|
||||||
template class static_module<text_module>;
|
template class static_module<text_module>;
|
||||||
|
|
||||||
void text_module::setup() {
|
text_module::text_module(const bar_settings& bar, string name_) : static_module<text_module>(bar, move(name_)) {
|
||||||
m_formatter->add("content", "", {});
|
m_formatter->add("content", "", {});
|
||||||
|
|
||||||
if (m_formatter->get("content")->value.empty()) {
|
if (m_formatter->get("content")->value.empty()) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace modules {
|
||||||
template class module<volume_module>;
|
template class module<volume_module>;
|
||||||
template class event_module<volume_module>;
|
template class event_module<volume_module>;
|
||||||
|
|
||||||
void volume_module::setup() {
|
volume_module::volume_module(const bar_settings& bar, string name_) : event_module<volume_module>(bar, move(name_)) {
|
||||||
// Load configuration values
|
// Load configuration values
|
||||||
string master_mixer_name{"Master"};
|
string master_mixer_name{"Master"};
|
||||||
string speaker_mixer_name;
|
string speaker_mixer_name;
|
||||||
|
|
|
@ -19,13 +19,8 @@ namespace modules {
|
||||||
/**
|
/**
|
||||||
* Construct module
|
* Construct module
|
||||||
*/
|
*/
|
||||||
xbacklight_module::xbacklight_module(const bar_settings& bar, string name)
|
xbacklight_module::xbacklight_module(const bar_settings& bar, string name_)
|
||||||
: static_module<xbacklight_module>(bar, move(name)), m_connection(connection::make()) {}
|
: static_module<xbacklight_module>(bar, move(name_)), m_connection(connection::make()) {
|
||||||
|
|
||||||
/**
|
|
||||||
* Bootstrap the module by grabbing all required components
|
|
||||||
*/
|
|
||||||
void xbacklight_module::setup() {
|
|
||||||
auto output = m_conf.get<string>(name(), "output", m_bar.monitor->name);
|
auto output = m_conf.get<string>(name(), "output", m_bar.monitor->name);
|
||||||
auto strict = m_conf.get<bool>(name(), "monitor-strict", false);
|
auto strict = m_conf.get<bool>(name(), "monitor-strict", false);
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,8 @@ namespace modules {
|
||||||
/**
|
/**
|
||||||
* Construct module
|
* Construct module
|
||||||
*/
|
*/
|
||||||
xkeyboard_module::xkeyboard_module(const bar_settings& bar, string name)
|
xkeyboard_module::xkeyboard_module(const bar_settings& bar, string name_)
|
||||||
: static_module<xkeyboard_module>(bar, move(name)), m_connection(connection::make()) {}
|
: static_module<xkeyboard_module>(bar, move(name_)), m_connection(connection::make()) {
|
||||||
|
|
||||||
/**
|
|
||||||
* Bootstrap the module
|
|
||||||
*/
|
|
||||||
void xkeyboard_module::setup() {
|
|
||||||
// Load config values
|
// Load config values
|
||||||
m_blacklist = m_conf.get_list<string>(name(), "blacklist", {});
|
m_blacklist = m_conf.get_list<string>(name(), "blacklist", {});
|
||||||
|
|
||||||
|
|
|
@ -64,13 +64,8 @@ namespace modules {
|
||||||
/**
|
/**
|
||||||
* Construct module
|
* Construct module
|
||||||
*/
|
*/
|
||||||
xwindow_module::xwindow_module(const bar_settings& bar, string name)
|
xwindow_module::xwindow_module(const bar_settings& bar, string name_)
|
||||||
: static_module<xwindow_module>(bar, name), m_connection(connection::make()) {}
|
: static_module<xwindow_module>(bar, move(name_)), m_connection(connection::make()) {
|
||||||
|
|
||||||
/**
|
|
||||||
* Bootstrap the module
|
|
||||||
*/
|
|
||||||
void xwindow_module::setup() {
|
|
||||||
// Initialize ewmh atoms
|
// Initialize ewmh atoms
|
||||||
if ((m_ewmh = ewmh_util::initialize()) == nullptr) {
|
if ((m_ewmh = ewmh_util::initialize()) == nullptr) {
|
||||||
throw module_error("Failed to initialize ewmh atoms");
|
throw module_error("Failed to initialize ewmh atoms");
|
||||||
|
|
|
@ -20,13 +20,8 @@ namespace modules {
|
||||||
/**
|
/**
|
||||||
* Construct module
|
* Construct module
|
||||||
*/
|
*/
|
||||||
xworkspaces_module::xworkspaces_module(const bar_settings& bar, string name)
|
xworkspaces_module::xworkspaces_module(const bar_settings& bar, string name_)
|
||||||
: static_module<xworkspaces_module>(bar, move(name)), m_connection(connection::make()) {}
|
: static_module<xworkspaces_module>(bar, move(name_)), m_connection(connection::make()) {
|
||||||
|
|
||||||
/**
|
|
||||||
* Bootstrap the module
|
|
||||||
*/
|
|
||||||
void xworkspaces_module::setup() {
|
|
||||||
// Load config values
|
// Load config values
|
||||||
m_pinworkspaces = m_conf.get<bool>(name(), "pin-workspaces", m_pinworkspaces);
|
m_pinworkspaces = m_conf.get<bool>(name(), "pin-workspaces", m_pinworkspaces);
|
||||||
m_click = m_conf.get<bool>(name(), "enable-click", m_click);
|
m_click = m_conf.get<bool>(name(), "enable-click", m_click);
|
||||||
|
|
Loading…
Reference in a new issue