// Copyright (C) 2026 Viorel Munteanu // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #pragma once #include #include #include // Fields that make sense to persist across invocations (one-shot flags like // -m/-r/--user don't belong here). Only the "global" section's log-level is // supported today; add more optional fields as more long options gain config-file // support. struct AppConfig { std::optional log_level; // global.log-level }; // $XDG_CONFIG_HOME/slocker-lite/config.yaml, or $HOME/.config/slocker-lite/config.yaml // if XDG_CONFIG_HOME is unset/empty. std::filesystem::path config_file_path(); // Loads and parses `path`'s "global" section. A missing file is not an error -- // returns a default-constructed AppConfig (nothing set). Unknown sections/keys are // ignored, so the format stays forward-compatible. Malformed YAML syntax logs a // specific error and returns nullopt. std::optional load_config_file(const std::filesystem::path& path);