Open Hubro opened 1 year ago
If I understood your question properly, all you need to do is either modify the hyprland.desktop
file in /usr/share/wayland-sessions
(downside, it will likely get overwritten after an update), or even better, create a new .desktop entry and modify the Exec=
to point to your script instead, then it'll show up on your login manager.
@tchofy True, I should probably do that, but it feels like a workaround whereas using an environment variable feels more like a proper solution. That way I don't have to modify or add any system files, which would be more work any time I replicate my setup to another machine.
Good idea though, I'll do this for now.
diff --git a/src/main.cpp b/src/main.cpp
index 3508043..3c63054 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -79,6 +79,16 @@ int main(int argc, char** argv) {
}
}
+ static const char* configPathEnv = getenv("HYPRLAND_CONFIG");
+ if (configPathEnv) {
+ if (!std::filesystem::exists(configPathEnv)) {
+ std::cerr << "[ ERROR ] Config path '" << configPathEnv << "' doesn't exist!\n";
+ return 1;
+ }
+ configPath = configPathEnv;
+ Debug::log(LOG, "Using config location specified in HYPRLAND_CONFIG: '%s'", configPath.c_str());
+ }
+
if (!ignoreSudo && Init::isSudo()) {
std::cerr << "[ ERROR ] Hyprland was launched with superuser priveleges, but the privileges check is not omitted.\n";
std::cerr << " Hint: Use the --i-am-really-stupid flag to omit that check.\n";
Build with
git apply config_from_env.patch
meson setup build
ninja -C build
You can test with
HYPRLAND_CONFIG=/path/to/config Hyprland
diff --git a/src/main.cpp b/src/main.cpp index 3508043..3c63054 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -79,6 +79,16 @@ int main(int argc, char** argv) { } } + static const char* configPathEnv = getenv("HYPRLAND_CONFIG"); + if (configPathEnv) { + if (!std::filesystem::exists(configPathEnv)) { + std::cerr << "[ ERROR ] Config path '" << configPathEnv << "' doesn't exist!\n"; + return 1; + } + configPath = configPathEnv; + Debug::log(LOG, "Using config location specified in HYPRLAND_CONFIG: '%s'", configPath.c_str()); + } + if (!ignoreSudo && Init::isSudo()) { std::cerr << "[ ERROR ] Hyprland was launched with superuser priveleges, but the privileges check is not omitted.\n"; std::cerr << " Hint: Use the --i-am-really-stupid flag to omit that check.\n";
Build with
git apply config_from_env.patch meson setup build ninja -C build
You can test with
HYPRLAND_CONFIG=/path/to/config Hyprland
Bump. Prolly, worth merging it into the main?
Description
I'm currently launching Hyprland with a script that ends with these lines:
Today I attempted to switch to a display manager (LightDM) and I got stuck on the fact that LightDM will just run
Hyprland
with no arguments, so there's no way for me to specify a config file.I use separate config files for separate machines, since they have different display configurations.
Is it currently possible to make Hyprland use a specific config file by setting an environment variable? I searched to the best of my ability, but I couldn't find any mention of such an environment variable.
Would this be possible to add? It would unlock the ability to use display managers for those of us who need separate config files per host.