Waybar/src/main.cpp

33 lines
777 B
C++
Raw Normal View History

2018-08-08 21:54:58 +00:00
#include <csignal>
2018-08-12 18:25:19 +00:00
#include <iostream>
#include "client.hpp"
2018-08-08 21:54:58 +00:00
int main(int argc, char* argv[]) {
2018-08-08 21:54:58 +00:00
try {
auto client = waybar::Client::inst();
std::signal(SIGUSR1, [](int /*signal*/) {
for (auto& bar : waybar::Client::inst()->bars) {
bar->toggle();
2018-08-08 21:54:58 +00:00
}
});
2019-03-18 17:46:44 +00:00
for (int sig = SIGRTMIN + 1; sig <= SIGRTMAX; ++sig) {
std::signal(sig, [](int sig) {
for (auto& bar : waybar::Client::inst()->bars) {
2019-03-18 17:46:44 +00:00
bar->handleSignal(sig);
}
});
}
auto ret = client->main(argc, argv);
delete client;
return ret;
2018-08-08 21:54:58 +00: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;
}
}