Repository: hyprwm/Hyprland
File: src/debug/HyprCtl.cpp (C++)

Code before:
    // Strip the keyword
    in = in.substr(firstSpacePos + 1);

    // Find the next space for the COMMAND and VALUE
    auto const secondSpacePos = in.find_first_of(' ');
    if (secondSpacePos == std::string::npos) // Handle the case where there's no second space (invalid input)
        return "Invalid input: command and value not properly formatted";

    // Extract COMMAND and VALUE
    const auto COMMAND = in.substr(0, secondSpacePos);
    const auto VALUE   = in.substr(secondSpacePos + 1);

    // If COMMAND is empty, handle accordingly
    if (COMMAND.empty())
        return "Invalid input: command is empty";

    std::string retval = g_pConfigManager->parseKeyword(COMMAND, VALUE);

    // if we are executing a dynamic source we have to reload everything, so every if will have a check for source.
    if (COMMAND == "monitor" || COMMAND == "source")
        g_pConfigManager->m_wantsMonitorReload = true; // for monitor keywords

    if (COMMAND.contains("monitorv2")) {
        // Updates configs for every monitorv2 rule
        g_pConfigManager->handleMonitorv2();
        g_pConfigManager->m_wantsMonitorReload = true;
        // Use this code to update only specified output (probably needs parser updates to remove parsing from here)
        // if (COMMAND.contains('[') && COMMAND.contains(']')) {
        //     const auto L = COMMAND.find_first_of('[');
        //     const auto R = COMMAND.find_last_of(']');

        //     if (L < R) {
        //         const auto output = COMMAND.substr(L + 1, R - L - 1);
        //         g_pConfigManager->handleMonitorv2(output);
        //         g_pConfigManager->m_wantsMonitorReload = true;
        //     }
        // }
    }

    if (COMMAND.contains("input") || COMMAND.contains("device") || COMMAND == "source") {
        g_pInputManager->setKeyboardLayout();     // update kb layout
        g_pInputManager->setPointerConfigs();     // update mouse cfgs
        g_pInputManager->setTouchDeviceConfigs(); // update touch device cfgs
        g_pInputManager->setTabletConfigs();      // update tablets
    }

    static auto PLAYOUT = CConfigValue<std::string>("general:layout");

    if (COMMAND.contains("general:layout"))
        g_pLayoutManager->switchToLayout(*PLAYOUT); // update layout


Review comment (suggestion):
don't do this. Instead, do `handleMonitorV2` on reload in the reload func. Here, just do:
```cpp
g_pEventLoopManager->doLater([this] {
g_pConfigManager->m_wantsMonitorReload = true;
});
```

Code after:
    // Strip the keyword
    in = in.substr(firstSpacePos + 1);

    // Find the next space for the COMMAND and VALUE
    auto const secondSpacePos = in.find_first_of(' ');
    if (secondSpacePos == std::string::npos) // Handle the case where there's no second space (invalid input)
        return "Invalid input: command and value not properly formatted";

    // Extract COMMAND and VALUE
    const auto COMMAND = in.substr(0, secondSpacePos);
    const auto VALUE   = in.substr(secondSpacePos + 1);

    // If COMMAND is empty, handle accordingly
    if (COMMAND.empty())
        return "Invalid input: command is empty";

    std::string retval = g_pConfigManager->parseKeyword(COMMAND, VALUE);

    // if we are executing a dynamic source we have to reload everything, so every if will have a check for source.
    if (COMMAND == "monitor" || COMMAND == "source")
        g_pConfigManager->m_wantsMonitorReload = true; // for monitor keywords

    if (COMMAND.contains("monitorv2"))
        g_pEventLoopManager->doLater([] { g_pConfigManager->m_wantsMonitorReload = true; });

    if (COMMAND.contains("input") || COMMAND.contains("device") || COMMAND == "source") {
        g_pInputManager->setKeyboardLayout();     // update kb layout
        g_pInputManager->setPointerConfigs();     // update mouse cfgs
        g_pInputManager->setTouchDeviceConfigs(); // update touch device cfgs
        g_pInputManager->setTabletConfigs();      // update tablets
    }

    static auto PLAYOUT = CConfigValue<std::string>("general:layout");

    if (COMMAND.contains("general:layout"))
        g_pLayoutManager->switchToLayout(*PLAYOUT); // update layout

    if (COMMAND.contains("decoration:screen_shader") || COMMAND == "source")
        g_pHyprOpenGL->m_reloadScreenShader = true;

    if (COMMAND.contains("blur") || COMMAND == "source") {
        for (auto& [m, rd] : g_pHyprOpenGL->m_monitorRenderResources) {
            rd.blurFBDirty = true;
        }
    }

    if (COMMAND.contains("misc:disable_autoreload"))
        g_pConfigManager->updateWatcher();

    // decorations will probably need a repaint
    if (COMMAND.contains("decoration:") || COMMAND.contains("border") || COMMAND == "workspace" || COMMAND.contains("zoom_factor") || COMMAND == "source" ||