1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00

Remove config inotify_watch

We use libuv now for watching the file
This commit is contained in:
patrick96 2021-09-11 14:56:08 +02:00 committed by Patrick Ziegler
parent ba50bf0bc6
commit 6ac5b7ebdd
3 changed files with 16 additions and 23 deletions

View file

@ -42,13 +42,12 @@ class controller
signals::ui::button_press, signals::ui::update_background> { signals::ui::button_press, signals::ui::update_background> {
public: public:
using make_type = unique_ptr<controller>; using make_type = unique_ptr<controller>;
static make_type make(unique_ptr<ipc>&& ipc, unique_ptr<inotify_watch>&& config_watch); static make_type make(unique_ptr<ipc>&& ipc);
explicit controller(connection&, signal_emitter&, const logger&, const config&, unique_ptr<bar>&&, unique_ptr<ipc>&&, explicit controller(connection&, signal_emitter&, const logger&, const config&, unique_ptr<bar>&&, unique_ptr<ipc>&&);
unique_ptr<inotify_watch>&&);
~controller(); ~controller();
bool run(bool writeback, string snapshot_dst); bool run(bool writeback, string snapshot_dst, bool confwatch);
void trigger_action(string&& input_data); void trigger_action(string&& input_data);
void trigger_quit(bool reload); void trigger_quit(bool reload);
@ -64,7 +63,7 @@ class controller
void notifier_handler(); void notifier_handler();
protected: protected:
void read_events(); void read_events(bool confwatch);
void process_inputdata(); void process_inputdata();
bool process_update(bool force); bool process_update(bool force);
@ -91,7 +90,6 @@ class controller
const config& m_conf; const config& m_conf;
unique_ptr<bar> m_bar; unique_ptr<bar> m_bar;
unique_ptr<ipc> m_ipc; unique_ptr<ipc> m_ipc;
unique_ptr<inotify_watch> m_confwatch;
std::unique_ptr<eventloop> eloop; std::unique_ptr<eventloop> eloop;

View file

@ -38,23 +38,22 @@ sig_atomic_t g_force_update{0};
/** /**
* Build controller instance * Build controller instance
*/ */
controller::make_type controller::make(unique_ptr<ipc>&& ipc, unique_ptr<inotify_watch>&& config_watch) { controller::make_type controller::make(unique_ptr<ipc>&& ipc) {
return factory_util::unique<controller>(connection::make(), signal_emitter::make(), logger::make(), config::make(), return factory_util::unique<controller>(connection::make(), signal_emitter::make(), logger::make(), config::make(),
bar::make(), forward<decltype(ipc)>(ipc), forward<decltype(config_watch)>(config_watch)); bar::make(), forward<decltype(ipc)>(ipc));
} }
/** /**
* Construct controller * Construct controller
*/ */
controller::controller(connection& conn, signal_emitter& emitter, const logger& logger, const config& config, controller::controller(connection& conn, signal_emitter& emitter, const logger& logger, const config& config,
unique_ptr<bar>&& bar, unique_ptr<ipc>&& ipc, unique_ptr<inotify_watch>&& confwatch) unique_ptr<bar>&& bar, unique_ptr<ipc>&& ipc)
: m_connection(conn) : m_connection(conn)
, m_sig(emitter) , m_sig(emitter)
, m_log(logger) , m_log(logger)
, m_conf(config) , m_conf(config)
, m_bar(forward<decltype(bar)>(bar)) , m_bar(forward<decltype(bar)>(bar))
, m_ipc(forward<decltype(ipc)>(ipc)) , m_ipc(forward<decltype(ipc)>(ipc)) {
, m_confwatch(forward<decltype(confwatch)>(confwatch)) {
if (m_conf.has("settings", "throttle-input-for")) { if (m_conf.has("settings", "throttle-input-for")) {
m_log.warn( m_log.warn(
"The config parameter 'settings.throttle-input-for' is deprecated, it will be removed in the future. Please " "The config parameter 'settings.throttle-input-for' is deprecated, it will be removed in the future. Please "
@ -101,7 +100,7 @@ controller::~controller() {
/** /**
* Run the main loop * Run the main loop
*/ */
bool controller::run(bool writeback, string snapshot_dst) { bool controller::run(bool writeback, string snapshot_dst, bool confwatch) {
m_log.info("Starting application"); m_log.info("Starting application");
m_log.trace("controller: Main thread id = %i", concurrency_util::thread_id(this_thread::get_id())); m_log.trace("controller: Main thread id = %i", concurrency_util::thread_id(this_thread::get_id()));
@ -135,7 +134,7 @@ bool controller::run(bool writeback, string snapshot_dst) {
m_connection.flush(); m_connection.flush();
read_events(); read_events(confwatch);
m_log.notice("Termination signal received, shutting down..."); m_log.notice("Termination signal received, shutting down...");
@ -278,7 +277,7 @@ static void notifier_cb_wrapper(uv_async_t *handle) {
/** /**
* Read events from configured file descriptors * Read events from configured file descriptors
*/ */
void controller::read_events() { void controller::read_events(bool confwatch) {
m_log.info("Entering event loop (thread-id=%lu)", this_thread::get_id()); m_log.info("Entering event loop (thread-id=%lu)", this_thread::get_id());
if (!m_writeback) { if (!m_writeback) {
@ -303,8 +302,8 @@ void controller::read_events() {
eloop->signal_handler(s, [this](int signum) { signal_handler(signum); }); eloop->signal_handler(s, [this](int signum) { signal_handler(signum); });
} }
if (m_confwatch) { if (confwatch) {
eloop->fs_event_handler(m_confwatch->path(), eloop->fs_event_handler(m_conf.filepath(),
[this](const char* path, int events, int status) { confwatch_handler(path, events, status); }); [this](const char* path, int events, int status) { confwatch_handler(path, events, status); });
} }

View file

@ -135,18 +135,14 @@ int main(int argc, char** argv) {
// Create controller and run application // Create controller and run application
//================================================== //==================================================
unique_ptr<ipc> ipc{}; unique_ptr<ipc> ipc{};
unique_ptr<inotify_watch> config_watch{};
if (conf.get(conf.section(), "enable-ipc", false)) { if (conf.get(conf.section(), "enable-ipc", false)) {
ipc = ipc::make(); ipc = ipc::make();
} }
if (cli->has("reload")) {
config_watch = inotify_util::make_watch(conf.filepath());
}
auto ctrl = controller::make(move(ipc), move(config_watch)); auto ctrl = controller::make(move(ipc));
if (!ctrl->run(cli->has("stdout"), cli->get("png"))) { if (!ctrl->run(cli->has("stdout"), cli->get("png"), cli->has("reload"))) {
reload = true; reload = true;
} }
} catch (const exception& err) { } catch (const exception& err) {