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

Code before:
}

int main(int argc, char** argv) {

    if (!getenv("XDG_RUNTIME_DIR"))
        throwError("XDG_RUNTIME_DIR is not set!");

    // export HYPRLAND_CMD
    std::string cmd = argv[0];
    for (int i = 1; i < argc; ++i)
        cmd += std::string(" ") + argv[i];

    setenv("HYPRLAND_CMD", cmd.c_str(), 1);
    setenv("XDG_BACKEND", "wayland", 1);
    setenv("XDG_SESSION_TYPE", "wayland", 1);
    setenv("_JAVA_AWT_WM_NONREPARENTING", "1", 1);
    setenv("MOZ_ENABLE_WAYLAND", "1", 1);

    // parse some args
    std::string              configPath;
    std::string              socketName;
    int                      socketFd   = -1;
    bool                     ignoreSudo = false, verifyConfig = false;

    if (argc > 1) {
        std::span<char*> args{ argv + 1, static_cast<std::size_t>(argc - 1) };

        for (auto it = args.begin(); it != args.end(); it++) {
            std::string_view value = *it;

            if (value == "--i-am-really-stupid" && !ignoreSudo) {
                std::println("[ WARNING ] Running Hyprland with superuser privileges might damage your system");

                ignoreSudo = true;
            } else if (value == "--socket") {
                if (std::next(it) == args.end()) {
                    help();

                    return 1;
                }

                socketName = *std::next(it);
                it++;
            } else if (value == "--wayland-fd") {
                if (std::next(it) == args.end()) {
                    help();

                    return 1;
                }

                try {

Review comment (suggestion):
rebase on main and use `Hyprutils::Memory::sc<T>`, `using Hyprutils::Memory`

Code after:
    --verify-config              - Do not run Hyprland, only print if the config has any errors
    --version           -v       - Print this binary's version)");
}

int main(int argc, char** argv) {

    if (!getenv("XDG_RUNTIME_DIR"))
        throwError("XDG_RUNTIME_DIR is not set!");

    // export HYPRLAND_CMD
    std::string cmd = argv[0];
    for (int i = 1; i < argc; ++i)
        cmd += std::string(" ") + argv[i];

    setenv("HYPRLAND_CMD", cmd.c_str(), 1);
    setenv("XDG_BACKEND", "wayland", 1);
    setenv("XDG_SESSION_TYPE", "wayland", 1);
    setenv("_JAVA_AWT_WM_NONREPARENTING", "1", 1);
    setenv("MOZ_ENABLE_WAYLAND", "1", 1);

    // parse some args
    std::string configPath;
    std::string socketName;
    int         socketFd   = -1;
    bool        ignoreSudo = false, verifyConfig = false;

    if (argc > 1) {
        std::span<char*> args{argv + 1, sc<std::size_t>(argc - 1)};

        for (auto it = args.begin(); it != args.end(); it++) {
            std::string_view value = *it;

            if (value == "--i-am-really-stupid" && !ignoreSudo) {
                std::println("[ WARNING ] Running Hyprland with superuser privileges might damage your system");

                ignoreSudo = true;
            } else if (value == "--socket") {
                if (std::next(it) == args.end()) {
                    help();

                    return 1;
                }

                socketName = *std::next(it);
                it++;
            } else if (value == "--wayland-fd") {
                if (std::next(it) == args.end()) {
                    help();

                    return 1;
                }