#include #include #include #include #include #include #include bool shouldRun = true; void my_handler(int s) { printf("Caught signal %d\n", s); shouldRun = false; } int main(int argc, char **argv) { // signal handler! struct sigaction sigIntHandler; sigIntHandler.sa_handler = my_handler; sigemptyset(&sigIntHandler.sa_mask); sigIntHandler.sa_flags = 0; sigaction(SIGINT, &sigIntHandler, nullptr); // Load Config... VUtils::Environment config{VUtils::FileHandler::getFromHomeDir("/.config/VulcanoLE/state.env").c_str()}; config.loadFile(); LOG(R"( [===============================================] _ _ _ _ _ _ _ _ _ / \ / \ / \ / \ / \ / \ / \ / \ / \ ( V | U | L | C | A | N | O ) ( L | E ) \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ [===============================================] )") HIDHelper helper{}; if (helper.openDevices() < 0) { ERR("Unable to find Keyboard!") exit(0); }; usleep(10000); auto runner = VisAudioRunner::create(); runner->env = &config; runner->plugins->init(&helper, runner->grabber); runner->init(); runner->plugins->setCurrentMode(config.getAsInt("visual_mode", 1)); while (shouldRun) { int mode; LOGWN("Enter Visual Mode: %d-%d < 0 = EXIT:\t", 0, 1) std::cin >> mode; if (std::cin.fail()) { ERR("ERROR -- You did not enter an integer") std::cin.clear(); std::cin.ignore(std::numeric_limits::max(), '\n'); continue; } if (mode < 0) { shouldRun = false; continue; } runner->plugins->setCurrentMode(mode); } DBG("Shutdown... Waiting for Thread to Finish!") runner->isActive = false; if (runner->thread.joinable()) { runner->thread.join(); } DBG("Exit!") usleep(1000); config.saveFile(); return 0; }