Skip to content

Commit

Permalink
config: add option to ignore empty input
Browse files Browse the repository at this point in the history
  • Loading branch information
YoussefAswad committed Mar 22, 2024
1 parent 0db5afb commit 9f84c0a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ static std::string getMainConfigPath() {
return getConfigDir() + "/hypr/hyprlock.conf";
}

CConfigManager::CConfigManager(std::string configPath) : m_config(configPath.empty() ? getMainConfigPath().c_str() : configPath.c_str(), Hyprlang::SConfigOptions{.throwAllErrors = true, .allowMissingConfig = configPath.empty()}) {
CConfigManager::CConfigManager(std::string configPath) :
m_config(configPath.empty() ? getMainConfigPath().c_str() : configPath.c_str(), Hyprlang::SConfigOptions{.throwAllErrors = true, .allowMissingConfig = configPath.empty()}) {
configCurrentPath = configPath.empty() ? getMainConfigPath() : configPath;
}

Expand All @@ -47,7 +48,7 @@ void CConfigManager::init() {
m_config.addConfigValue("general:grace", Hyprlang::INT{0});
m_config.addConfigValue("general:no_fade_in", Hyprlang::INT{0});
m_config.addConfigValue("general:no_fade_out", Hyprlang::INT{0});

m_config.addConfigValue("general:ignore_empty_input", Hyprlang::INT{0});

m_config.addSpecialCategory("background", Hyprlang::SSpecialCategoryOptions{.key = nullptr, .anonymousKeyBased = true});
m_config.addSpecialConfigValue("background", "monitor", Hyprlang::STRING{""});
Expand Down
8 changes: 8 additions & 0 deletions src/core/hyprlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,14 @@ void CHyprlock::onKey(uint32_t key, bool down) {
}
} else if (SYM == XKB_KEY_Return || SYM == XKB_KEY_KP_Enter) {
Debug::log(LOG, "Authenticating");

static auto* const PIGNOREEMPTY = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:ignore_empty_input");

if (m_sPasswordState.passBuffer.empty() && **PIGNOREEMPTY) {
Debug::log(LOG, "Ignoring empty input");
return;
}

m_sPasswordState.result = g_pPassword->verify(m_sPasswordState.passBuffer);
} else if (SYM == XKB_KEY_Escape) {
Debug::log(LOG, "Clearing password buffer");
Expand Down

0 comments on commit 9f84c0a

Please sign in to comment.