mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-07 19:05:58 +01:00
commit
5af26a451a
4 changed files with 45 additions and 15 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -13,6 +13,7 @@ build/
|
|||
result
|
||||
/.vscode/
|
||||
.envrc
|
||||
.cache
|
||||
|
||||
*.o
|
||||
*-protocol.c
|
||||
|
|
|
@ -147,6 +147,8 @@ public:
|
|||
CWindow* getX11Parent(CWindow*);
|
||||
void scheduleFrameForMonitor(SMonitor*);
|
||||
|
||||
std::string explicitConfigPath;
|
||||
|
||||
private:
|
||||
void initAllSignals();
|
||||
void setRandomSplash();
|
||||
|
|
|
@ -12,8 +12,15 @@
|
|||
|
||||
CConfigManager::CConfigManager() {
|
||||
setDefaultVars();
|
||||
|
||||
std::string CONFIGPATH;
|
||||
if (g_pCompositor->explicitConfigPath == "") {
|
||||
static const char* const ENVHOME = getenv("HOME");
|
||||
const std::string CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf");
|
||||
CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf");
|
||||
} else {
|
||||
CONFIGPATH = g_pCompositor->explicitConfigPath;
|
||||
}
|
||||
|
||||
configPaths.emplace_back(CONFIGPATH);
|
||||
|
||||
Debug::disableLogs = &configValues["debug:disable_logs"].intValue;
|
||||
|
@ -801,9 +808,16 @@ void CConfigManager::loadConfigLoadVars() {
|
|||
// paths
|
||||
configPaths.clear();
|
||||
|
||||
std::string CONFIGPATH;
|
||||
|
||||
static const char* const ENVHOME = getenv("HOME");
|
||||
const std::string CONFIGPARENTPATH = ENVHOME + (std::string) "/.config/hypr/";
|
||||
const std::string CONFIGPATH = CONFIGPARENTPATH + (ISDEBUG ? "hyprlandd.conf" : "hyprland.conf");
|
||||
|
||||
if (g_pCompositor->explicitConfigPath == "") {
|
||||
CONFIGPATH = CONFIGPARENTPATH + (ISDEBUG ? "hyprlandd.conf" : "hyprland.conf");
|
||||
} else {
|
||||
CONFIGPATH = g_pCompositor->explicitConfigPath;
|
||||
}
|
||||
|
||||
configPaths.push_back(CONFIGPATH);
|
||||
|
||||
|
@ -811,6 +825,7 @@ void CConfigManager::loadConfigLoadVars() {
|
|||
ifs.open(CONFIGPATH);
|
||||
|
||||
if (!ifs.good()) {
|
||||
if(g_pCompositor->explicitConfigPath == "") {
|
||||
Debug::log(WARN, "Config reading error. (No file? Attempting to generate, backing up old one if exists)");
|
||||
try {
|
||||
std::filesystem::rename(CONFIGPATH, CONFIGPATH + ".backup");
|
||||
|
@ -824,6 +839,7 @@ void CConfigManager::loadConfigLoadVars() {
|
|||
parseError = "Broken config file! (Could not create directory)";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::ofstream ofs;
|
||||
ofs.open(CONFIGPATH, std::ios::trunc);
|
||||
|
|
11
src/main.cpp
11
src/main.cpp
|
@ -15,9 +15,19 @@ int main(int argc, char** argv) {
|
|||
throw std::runtime_error("XDG_RUNTIME_DIR is not set!");
|
||||
|
||||
// parse some args
|
||||
std::string configPath;
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (!strcmp(argv[i], "--i-am-really-stupid"))
|
||||
ignoreSudo = true;
|
||||
else if ((!strcmp(argv[i], "-c") || !strcmp(argv[i], "--config")) && argc >= i + 2) {
|
||||
configPath = std::string(argv[++i]);
|
||||
Debug::log(LOG, "Using config location %s.", configPath.c_str());
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
system("mkdir -p /tmp/hypr");
|
||||
|
@ -37,6 +47,7 @@ int main(int argc, char** argv) {
|
|||
// let's init the compositor.
|
||||
// it initializes basic Wayland stuff in the constructor.
|
||||
g_pCompositor = std::make_unique<CCompositor>();
|
||||
g_pCompositor->explicitConfigPath = configPath;
|
||||
|
||||
Debug::log(LOG, "Hyprland init finished.");
|
||||
|
||||
|
|
Loading…
Reference in a new issue