hyprlock/src/main.cpp

59 lines
1.9 KiB
C++
Raw Normal View History

2024-02-19 00:08:03 +01:00
#include "config/ConfigManager.hpp"
#include "core/hyprlock.hpp"
void help() {
std::cout << "Usage: hyprlock [options]\n\n"
"Options:\n"
" -v, --verbose - Enable verbose logging\n"
" -q, --quiet - Disable logging\n"
" -c FILE, --config FILE - Specify config file to use\n"
" --display (display) - Specify the Wayland display to connect to\n"
" --immediate - Lock immediately, ignoring any configured grace period\n"
" -h, --help - Show this help message\n";
}
2024-02-19 16:20:52 +01:00
int main(int argc, char** argv, char** envp) {
std::string configPath;
2024-02-19 16:20:52 +01:00
std::string wlDisplay;
bool immediate = false;
2024-02-19 16:20:52 +01:00
2024-02-19 00:08:03 +01:00
for (int i = 1; i < argc; ++i) {
std::string arg = argv[i];
if (arg == "--verbose" || arg == "-v")
Debug::verbose = true;
else if (arg == "--quiet" || arg == "-q")
Debug::quiet = true;
2024-02-19 16:20:52 +01:00
else if ((arg == "--config" || arg == "-c") && i + 1 < argc)
configPath = argv[++i];
2024-02-20 01:11:19 +01:00
else if (arg == "--display" && i + 1 < argc) {
2024-02-19 16:20:52 +01:00
wlDisplay = argv[i + 1];
2024-02-20 01:11:19 +01:00
i++;
} else if (arg == "--immediate") {
immediate = true;
} else if (arg == "--help" || arg == "-h") {
help();
return 0;
}
2024-02-19 00:08:03 +01:00
}
try {
g_pConfigManager = std::make_unique<CConfigManager>(configPath);
2024-02-19 00:08:03 +01:00
g_pConfigManager->init();
2024-02-19 16:20:52 +01:00
} catch (const char* err) {
2024-02-19 00:08:03 +01:00
Debug::log(CRIT, "ConfigManager threw: {}", err);
std::string strerr = err;
if (strerr.contains("File does not exist"))
Debug::log(NONE, " Make sure you have a config.");
return 1;
}
g_pHyprlock = std::make_unique<CHyprlock>(wlDisplay, immediate);
2024-02-19 00:08:03 +01:00
g_pHyprlock->run();
return 0;
}