mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2026-02-04 16:15:40 +00:00
config: refuse to start with a bad config
This commit is contained in:
@ -48,7 +48,7 @@ CConfigManager::CConfigManager(const std::string& configPath) :
|
||||
m_currentConfigPath = configPath.empty() ? getMainConfigPath() : configPath;
|
||||
}
|
||||
|
||||
void CConfigManager::init() {
|
||||
bool CConfigManager::init() {
|
||||
m_config.addConfigValue("splash", Hyprlang::INT{1});
|
||||
m_config.addConfigValue("splash_offset", Hyprlang::INT{20});
|
||||
m_config.addConfigValue("splash_opacity", Hyprlang::FLOAT{0.8});
|
||||
@ -64,10 +64,13 @@ void CConfigManager::init() {
|
||||
|
||||
auto result = m_config.parse();
|
||||
|
||||
if (result.error)
|
||||
g_logger->log(LOG_ERR, "Config has errors:\n{}\nProceeding ignoring faulty entries", result.getError());
|
||||
if (result.error) {
|
||||
g_logger->log(LOG_ERR, "Config has errors:\n{}", result.getError());
|
||||
return false;
|
||||
}
|
||||
|
||||
g_matcher->addStates(getSettings());
|
||||
return true;
|
||||
}
|
||||
|
||||
Hyprlang::CConfig* CConfigManager::hyprlang() {
|
||||
|
||||
@ -22,7 +22,7 @@ class CConfigManager {
|
||||
|
||||
constexpr static const uint32_t SETTING_INVALID = 0;
|
||||
|
||||
void init();
|
||||
bool init();
|
||||
Hyprlang::CConfig* hyprlang();
|
||||
|
||||
std::vector<SSetting> getSettings();
|
||||
|
||||
@ -31,7 +31,8 @@ int main(int argc, const char** argv, const char** envp) {
|
||||
g_logger->log(LOG_DEBUG, "Welcome to hyprpaper!\nbuilt from commit {} ({})", GIT_COMMIT_HASH, GIT_COMMIT_MESSAGE);
|
||||
|
||||
g_config = makeUnique<CConfigManager>(std::string{parser.getString("config").value_or("")});
|
||||
g_config->init();
|
||||
if (!g_config->init())
|
||||
return 1;
|
||||
|
||||
g_ui = makeUnique<CUI>();
|
||||
g_ui->run();
|
||||
|
||||
Reference in New Issue
Block a user