2018-08-08 23:54:58 +02:00
|
|
|
#include <csignal>
|
2018-08-12 20:25:19 +02:00
|
|
|
#include <iostream>
|
2019-04-17 14:19:04 +02:00
|
|
|
#include "client.hpp"
|
2018-08-08 23:54:58 +02:00
|
|
|
|
2019-04-17 14:19:04 +02:00
|
|
|
int main(int argc, char* argv[]) {
|
2018-08-08 23:54:58 +02:00
|
|
|
try {
|
2019-04-18 17:43:16 +02:00
|
|
|
auto client = waybar::Client::inst();
|
2019-04-17 14:19:04 +02:00
|
|
|
std::signal(SIGUSR1, [](int /*signal*/) {
|
2019-04-18 17:43:16 +02:00
|
|
|
for (auto& bar : waybar::Client::inst()->bars) {
|
2018-11-23 16:04:29 +01:00
|
|
|
bar->toggle();
|
2018-08-08 23:54:58 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-03-18 18:46:44 +01:00
|
|
|
for (int sig = SIGRTMIN + 1; sig <= SIGRTMAX; ++sig) {
|
2019-04-18 17:43:16 +02:00
|
|
|
std::signal(sig, [](int sig) {
|
|
|
|
for (auto& bar : waybar::Client::inst()->bars) {
|
2019-03-18 18:46:44 +01:00
|
|
|
bar->handleSignal(sig);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-04-18 17:43:16 +02:00
|
|
|
auto ret = client->main(argc, argv);
|
|
|
|
delete client;
|
|
|
|
return ret;
|
2018-08-08 23:54:58 +02:00
|
|
|
} catch (const std::exception& e) {
|
|
|
|
std::cerr << e.what() << std::endl;
|
|
|
|
return 1;
|
|
|
|
} catch (const Glib::Exception& e) {
|
|
|
|
std::cerr << e.what().c_str() << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|