diff options
| author | Vaxry <vaxry@vaxry.net> | 2026-05-07 00:39:04 +0100 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2026-05-07 00:39:04 +0100 |
| commit | 4fab2afced44e745d5af85184fd9c3997af2374a (patch) | |
| tree | f38b89f120ac4a96c04ff470e4abd770b22ba546 /src/config | |
| parent | 78b8ce229c098a9911e2fe0dbc02f4b8340f70a9 (diff) | |
config: use lua by default, generate lua if no config present
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/ConfigManager.cpp | 4 | ||||
| -rw-r--r-- | src/config/legacy/ConfigManager.cpp | 5 | ||||
| -rw-r--r-- | src/config/legacy/DefaultConfig.hpp | 27 | ||||
| -rw-r--r-- | src/config/lua/ConfigManager.cpp | 6 | ||||
| -rw-r--r-- | src/config/lua/DefaultConfig.hpp | 6 | ||||
| -rw-r--r-- | src/config/supplementary/jeremy/Jeremy.cpp | 8 |
6 files changed, 34 insertions, 22 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index aaad6dc9..297e9c04 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -30,7 +30,7 @@ bool Config::initConfigManager() { Log::logger->log(Log::DEBUG, "[cfg] Regular config at {}", filePath.string()); std::error_code ec; - if (std::filesystem::exists(filePath, ec) && !ec && filePath.extension() == ".lua") { + if (filePath.extension() == ".lua") { // we have lua! Log::logger->log(Log::DEBUG, "[cfg] Using lua config found at {}", filePath.string()); g_mgr = makeUnique<Lua::CConfigManager>(); @@ -42,7 +42,7 @@ bool Config::initConfigManager() { } else { Log::logger->log(Log::DEBUG, "[cfg] Config is either explicit or special."); - if (filePath.extension() == ".lua" || filePath.extension() == "lua") { + if (filePath.extension() == ".lua") { Log::logger->log(Log::DEBUG, "[cfg] Config is lua, loading lua mgr"); g_mgr = makeUnique<Lua::CConfigManager>(); } else { diff --git a/src/config/legacy/ConfigManager.cpp b/src/config/legacy/ConfigManager.cpp index 04d76260..08bfe086 100644 --- a/src/config/legacy/ConfigManager.cpp +++ b/src/config/legacy/ConfigManager.cpp @@ -2096,10 +2096,9 @@ std::expected<void, std::string> CConfigManager::generateDefaultConfig(const std if (!ofs.good()) return std::unexpected("Config could not be generated."); - if (!safeMode) { - ofs << AUTOGENERATED_PREFIX; + if (!safeMode) ofs << EXAMPLE_CONFIG; - } else { + else { std::string n = std::string{EXAMPLE_CONFIG}; replaceInString(n, "\n$menu = hyprlauncher\n", "\n$menu = hyprland-run\n"); ofs << n; diff --git a/src/config/legacy/DefaultConfig.hpp b/src/config/legacy/DefaultConfig.hpp index dea4ec51..284a7b48 100644 --- a/src/config/legacy/DefaultConfig.hpp +++ b/src/config/legacy/DefaultConfig.hpp @@ -2,17 +2,22 @@ #include <string_view> -inline constexpr std::string_view AUTOGENERATED_PREFIX = R"#( -# ####################################################################################### -# AUTOGENERATED HYPRLAND CONFIG. -# EDIT THIS CONFIG ACCORDING TO THE WIKI INSTRUCTIONS. -# ####################################################################################### +inline constexpr std::string_view EXAMPLE_CONFIG = R"#( -autogenerated = 1 # remove this line to remove the warning +# This config is a STUB! This should never be generated. +# Use the default lua config from https://github.com/hyprwm/Hyprland/blob/main/example/hyprland.lua -)#"; -inline constexpr char EXAMPLE_CONFIG_BYTES[] = { -#embed "../../../example/hyprland.conf" -}; +autogenerated = 1 + +$mainMod = SUPER +$terminal = kitty +$fileManager = dolphin +$menu = hyprlauncher -inline constexpr std::string_view EXAMPLE_CONFIG = {EXAMPLE_CONFIG_BYTES, sizeof(EXAMPLE_CONFIG_BYTES)}; +bind = $mainMod, Q, exec, $terminal +bind = $mainMod, C, killactive, +bind = $mainMod, M, exec, command -v hyprshutdown >/dev/null 2>&1 && hyprshutdown || hyprctl dispatch exit +bind = $mainMod, E, exec, $fileManager +bind = $mainMod, V, togglefloating, +bind = $mainMod, R, exec, $menu +)#"; diff --git a/src/config/lua/ConfigManager.cpp b/src/config/lua/ConfigManager.cpp index 0f0c1030..8b90b4be 100644 --- a/src/config/lua/ConfigManager.cpp +++ b/src/config/lua/ConfigManager.cpp @@ -805,10 +805,10 @@ std::expected<void, std::string> CConfigManager::generateDefaultConfig(const std return std::unexpected("Config could not be generated."); if (!safeMode) { - ofs << AUTOGENERATED_PREFIX; - ofs << EXAMPLE_CONFIG; + ofs << AUTOGENERATED_PREFIX_LUA; + ofs << EXAMPLE_CONFIG_LUA; } else { - std::string n = std::string{EXAMPLE_CONFIG}; + std::string n = std::string{EXAMPLE_CONFIG_LUA}; replaceInString(n, "\nlocal menu = \"hyprlauncher\"\n", "\nlocal menu = \"hyprland-run\"\n"); ofs << n; } diff --git a/src/config/lua/DefaultConfig.hpp b/src/config/lua/DefaultConfig.hpp index 6fe92679..8911a8cb 100644 --- a/src/config/lua/DefaultConfig.hpp +++ b/src/config/lua/DefaultConfig.hpp @@ -2,7 +2,7 @@ #include <string_view> -inline constexpr std::string_view AUTOGENERATED_PREFIX = R"#( +inline constexpr std::string_view AUTOGENERATED_PREFIX_LUA = R"#( -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- AUTOGENERATED HYPRLAND CONFIG. -- -- EDIT THIS CONFIG ACCORDING TO THE WIKI INSTRUCTIONS. -- @@ -11,8 +11,8 @@ inline constexpr std::string_view AUTOGENERATED_PREFIX = R"#( hl.config({ autogenerated = true }) -- remove this line to remove the warning )#"; -inline constexpr char EXAMPLE_CONFIG_BYTES[] = { +inline constexpr char EXAMPLE_CONFIG_BYTES_LUA[] = { #embed "../../../example/hyprland.lua" }; -inline constexpr std::string_view EXAMPLE_CONFIG = {EXAMPLE_CONFIG_BYTES, sizeof(EXAMPLE_CONFIG_BYTES)}; +inline constexpr std::string_view EXAMPLE_CONFIG_LUA = {EXAMPLE_CONFIG_BYTES_LUA, sizeof(EXAMPLE_CONFIG_BYTES_LUA)}; diff --git a/src/config/supplementary/jeremy/Jeremy.cpp b/src/config/supplementary/jeremy/Jeremy.cpp index e8be2914..67b7b493 100644 --- a/src/config/supplementary/jeremy/Jeremy.cpp +++ b/src/config/supplementary/jeremy/Jeremy.cpp @@ -16,8 +16,16 @@ std::expected<SConfigStateReply, std::string> Jeremy::getMainConfigPath() { std::error_code ec; auto p2 = p; p2.replace_extension(".lua"); + + // if we don't have a .conf file, use lua by default. + if (!std::filesystem::exists(p, ec) || ec) + return p2; + + // if we have a .lua file, use that if (std::filesystem::exists(p2, ec) && !ec) return p2; + + // otherwise use .conf return p; }; |
