waybar/src/main.cpp

38 lines
812 B
C++
Raw Normal View History

2018-08-08 23:54:58 +02:00
#include <csignal>
2018-08-12 20:25:19 +02:00
#include <iostream>
#include "client.hpp"
2018-08-08 23:54:58 +02:00
namespace waybar {
2018-08-16 14:29:41 +02:00
static Client* client;
} // namespace waybar
2018-08-08 23:54:58 +02:00
int main(int argc, char* argv[]) {
2018-08-08 23:54:58 +02:00
try {
waybar::Client c(argc, argv);
waybar::client = &c;
std::signal(SIGUSR1, [](int /*signal*/) {
2018-08-08 23:54:58 +02:00
for (auto& bar : waybar::client->bars) {
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) {
std::signal(sig, [](int sig /*signal*/) {
2019-03-18 18:46:44 +01:00
for (auto& bar : waybar::client->bars) {
bar->handleSignal(sig);
}
});
}
2018-08-08 23:54:58 +02:00
return c.main(argc, argv);
} 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;
}
}