2022-03-16 20:50:55 +01:00
|
|
|
#include "defines.hpp"
|
|
|
|
#include "debug/Log.hpp"
|
2022-03-16 21:37:21 +01:00
|
|
|
#include "Compositor.hpp"
|
2022-03-17 15:53:45 +01:00
|
|
|
#include "config/ConfigManager.hpp"
|
2022-05-19 19:28:15 +02:00
|
|
|
#include "init/initHelpers.hpp"
|
2022-06-03 17:48:07 +02:00
|
|
|
#include <iostream>
|
2022-05-19 19:28:15 +02:00
|
|
|
|
|
|
|
// I am a bad bad boy and have used some global vars here,
|
|
|
|
// just for this file
|
|
|
|
bool ignoreSudo = false;
|
2022-03-16 20:50:55 +01:00
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
|
|
|
|
if (!getenv("XDG_RUNTIME_DIR"))
|
2022-07-06 16:17:58 +02:00
|
|
|
throw std::runtime_error("XDG_RUNTIME_DIR is not set!");
|
2022-03-16 20:50:55 +01:00
|
|
|
|
2022-05-19 19:28:15 +02:00
|
|
|
// parse some args
|
2022-07-14 22:55:24 +02:00
|
|
|
std::string configPath;
|
2022-05-19 19:28:15 +02:00
|
|
|
for (int i = 1; i < argc; ++i) {
|
|
|
|
if (!strcmp(argv[i], "--i-am-really-stupid"))
|
|
|
|
ignoreSudo = true;
|
2022-07-14 23:09:31 +02:00
|
|
|
else if ((!strcmp(argv[i], "-c") || !strcmp(argv[i], "--config")) && argc >= i + 2) {
|
2022-07-14 22:55:24 +02:00
|
|
|
configPath = std::string(argv[++i]);
|
|
|
|
Debug::log(LOG, "Using config location %s.", configPath.c_str());
|
2022-07-14 23:09:31 +02:00
|
|
|
} else {
|
|
|
|
std::cout << "Hyprland usage: Hyprland [arg [...]].\n\nArguments:\n" <<
|
|
|
|
"--help -h | Show this help message\n" <<
|
|
|
|
"--config -c | Specify config file to use\n";
|
|
|
|
return 1;
|
2022-07-14 22:55:24 +02:00
|
|
|
}
|
2022-05-19 19:28:15 +02:00
|
|
|
}
|
|
|
|
|
2022-06-03 17:41:57 +02:00
|
|
|
system("mkdir -p /tmp/hypr");
|
|
|
|
|
2022-05-19 19:28:15 +02:00
|
|
|
if (!ignoreSudo) {
|
|
|
|
if (Init::isSudo()) {
|
2022-06-03 17:48:07 +02:00
|
|
|
std::cout << "Hyprland shall not be run as the root user. If you really want to, use the --i-am-really-stupid flag.\n";
|
|
|
|
return 1;
|
2022-05-19 19:28:15 +02:00
|
|
|
}
|
|
|
|
} else {
|
2022-06-03 17:48:07 +02:00
|
|
|
std::cout << "Running with ignored root checks, I surely hope you know what you're doing.\n";
|
2022-05-19 19:28:15 +02:00
|
|
|
sleep(1);
|
|
|
|
}
|
|
|
|
|
2022-06-03 17:48:07 +02:00
|
|
|
std::cout << "Welcome to Hyprland!\n";
|
2022-03-16 21:37:21 +01:00
|
|
|
|
2022-08-22 15:50:02 +02:00
|
|
|
const auto LOGWLR = getenv("HYPRLAND_LOG_WLR");
|
|
|
|
if (LOGWLR && std::string(LOGWLR) == "1")
|
2022-08-22 18:50:38 +02:00
|
|
|
wlr_log_init(WLR_DEBUG, Debug::wlrLog);
|
2022-08-22 15:50:02 +02:00
|
|
|
|
2022-03-16 21:37:21 +01:00
|
|
|
// let's init the compositor.
|
|
|
|
// it initializes basic Wayland stuff in the constructor.
|
|
|
|
g_pCompositor = std::make_unique<CCompositor>();
|
2022-07-14 22:55:24 +02:00
|
|
|
g_pCompositor->explicitConfigPath = configPath;
|
2022-03-16 21:37:21 +01:00
|
|
|
|
|
|
|
Debug::log(LOG, "Hyprland init finished.");
|
|
|
|
|
|
|
|
// If all's good to go, start.
|
|
|
|
g_pCompositor->startCompositor();
|
2022-03-16 20:50:55 +01:00
|
|
|
|
2022-03-16 21:37:21 +01:00
|
|
|
// If we are here it means we got yote.
|
|
|
|
Debug::log(LOG, "Hyprland reached the end.");
|
2022-03-16 20:50:55 +01:00
|
|
|
|
2022-08-25 21:35:47 +02:00
|
|
|
wl_display_destroy_clients(g_pCompositor->m_sWLDisplay);
|
2022-08-28 11:19:08 +02:00
|
|
|
|
|
|
|
// kill all clients
|
|
|
|
for (auto& c : g_pCompositor->m_dProcessPIDsOnShutdown)
|
|
|
|
kill(c, SIGKILL);
|
|
|
|
|
2022-08-25 21:35:47 +02:00
|
|
|
wl_display_destroy(g_pCompositor->m_sWLDisplay);
|
2022-03-17 19:03:15 +01:00
|
|
|
|
2022-03-16 20:50:55 +01:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|