mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 00:25:57 +01:00
add config flag
you can now specify a config with -c <path>
This commit is contained in:
parent
316589406f
commit
01fc3d6068
3 changed files with 39 additions and 15 deletions
|
@ -147,6 +147,8 @@ public:
|
||||||
CWindow* getX11Parent(CWindow*);
|
CWindow* getX11Parent(CWindow*);
|
||||||
void scheduleFrameForMonitor(SMonitor*);
|
void scheduleFrameForMonitor(SMonitor*);
|
||||||
|
|
||||||
|
std::string explicitConfigPath;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initAllSignals();
|
void initAllSignals();
|
||||||
void setRandomSplash();
|
void setRandomSplash();
|
||||||
|
|
|
@ -12,8 +12,15 @@
|
||||||
|
|
||||||
CConfigManager::CConfigManager() {
|
CConfigManager::CConfigManager() {
|
||||||
setDefaultVars();
|
setDefaultVars();
|
||||||
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");
|
std::string CONFIGPATH;
|
||||||
|
if (g_pCompositor->explicitConfigPath == "") {
|
||||||
|
static const char* const ENVHOME = getenv("HOME");
|
||||||
|
CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf");
|
||||||
|
} else {
|
||||||
|
CONFIGPATH = g_pCompositor->explicitConfigPath;
|
||||||
|
}
|
||||||
|
|
||||||
configPaths.emplace_back(CONFIGPATH);
|
configPaths.emplace_back(CONFIGPATH);
|
||||||
|
|
||||||
Debug::disableLogs = &configValues["debug:disable_logs"].intValue;
|
Debug::disableLogs = &configValues["debug:disable_logs"].intValue;
|
||||||
|
@ -801,9 +808,16 @@ void CConfigManager::loadConfigLoadVars() {
|
||||||
// paths
|
// paths
|
||||||
configPaths.clear();
|
configPaths.clear();
|
||||||
|
|
||||||
|
std::string CONFIGPATH;
|
||||||
|
|
||||||
static const char* const ENVHOME = getenv("HOME");
|
static const char* const ENVHOME = getenv("HOME");
|
||||||
const std::string CONFIGPARENTPATH = ENVHOME + (std::string) "/.config/hypr/";
|
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);
|
configPaths.push_back(CONFIGPATH);
|
||||||
|
|
||||||
|
@ -811,18 +825,20 @@ void CConfigManager::loadConfigLoadVars() {
|
||||||
ifs.open(CONFIGPATH);
|
ifs.open(CONFIGPATH);
|
||||||
|
|
||||||
if (!ifs.good()) {
|
if (!ifs.good()) {
|
||||||
Debug::log(WARN, "Config reading error. (No file? Attempting to generate, backing up old one if exists)");
|
if(g_pCompositor->explicitConfigPath == "") {
|
||||||
try {
|
Debug::log(WARN, "Config reading error. (No file? Attempting to generate, backing up old one if exists)");
|
||||||
std::filesystem::rename(CONFIGPATH, CONFIGPATH + ".backup");
|
try {
|
||||||
} catch(...) { /* Probably doesn't exist */}
|
std::filesystem::rename(CONFIGPATH, CONFIGPATH + ".backup");
|
||||||
|
} catch(...) { /* Probably doesn't exist */}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!std::filesystem::is_directory(CONFIGPARENTPATH))
|
if (!std::filesystem::is_directory(CONFIGPARENTPATH))
|
||||||
std::filesystem::create_directories(CONFIGPARENTPATH);
|
std::filesystem::create_directories(CONFIGPARENTPATH);
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
parseError = "Broken config file! (Could not create directory)";
|
parseError = "Broken config file! (Could not create directory)";
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ofstream ofs;
|
std::ofstream ofs;
|
||||||
|
|
|
@ -15,9 +15,14 @@ int main(int argc, char** argv) {
|
||||||
throw std::runtime_error("XDG_RUNTIME_DIR is not set!");
|
throw std::runtime_error("XDG_RUNTIME_DIR is not set!");
|
||||||
|
|
||||||
// parse some args
|
// parse some args
|
||||||
|
std::string configPath;
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
if (!strcmp(argv[i], "--i-am-really-stupid"))
|
if (!strcmp(argv[i], "--i-am-really-stupid"))
|
||||||
ignoreSudo = true;
|
ignoreSudo = true;
|
||||||
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
system("mkdir -p /tmp/hypr");
|
system("mkdir -p /tmp/hypr");
|
||||||
|
@ -37,6 +42,7 @@ int main(int argc, char** argv) {
|
||||||
// let's init the compositor.
|
// let's init the compositor.
|
||||||
// it initializes basic Wayland stuff in the constructor.
|
// it initializes basic Wayland stuff in the constructor.
|
||||||
g_pCompositor = std::make_unique<CCompositor>();
|
g_pCompositor = std::make_unique<CCompositor>();
|
||||||
|
g_pCompositor->explicitConfigPath = configPath;
|
||||||
|
|
||||||
Debug::log(LOG, "Hyprland init finished.");
|
Debug::log(LOG, "Hyprland init finished.");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue