mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-11-16 23:05:58 +01:00
config: add option to ignore empty input (#218)
This commit is contained in:
parent
0db5afb9d6
commit
230f8aadb5
2 changed files with 11 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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{""});
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue