diff options
| author | BossCode45 <boss@tehbox.org> | 2025-05-06 18:00:13 +1200 |
|---|---|---|
| committer | BossCode45 <boss@tehbox.org> | 2025-05-06 18:00:13 +1200 |
| commit | ecc333d03abe308ce47c05345f8f90ae6a01b215 (patch) | |
| tree | 6aa4cc449bf9289c2ac8414931f8a536299c4490 /src/main.cpp | |
| parent | d1d4a63d4473cd4910b678cf5b385f622186fbd3 (diff) | |
| parent | bc9c5f43f5c8108c3d617716b2c3aeaf553a03e3 (diff) | |
| download | YATwm-ecc333d03abe308ce47c05345f8f90ae6a01b215.tar.gz YATwm-ecc333d03abe308ce47c05345f8f90ae6a01b215.zip | |
Merge branch 'nix'
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/main.cpp b/src/main.cpp index da1ae9b..45e4eba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,6 @@ #include <X11/Xutil.h> #include <X11/extensions/Xrandr.h> -#include <bits/getopt_core.h> #include <libnotify/notification.h> #include <libnotify/notify.h> @@ -18,6 +17,7 @@ #include <iostream> #include <map> #include <ostream> +#include <regex> #include <string> #include <sys/poll.h> #include <sys/select.h> @@ -1029,13 +1029,15 @@ int main(int argc, char** argv) { int versionFlag = 0; bool immediateExit = false; + string configLocation = ""; while(1) { static option long_options[] = {{"version", no_argument, &versionFlag, 1}, + {"config", required_argument, NULL, 'c'}, {0, 0, 0, 0}}; int optionIndex; - char c = getopt_long(argc, argv, "v", long_options, &optionIndex); + char c = getopt_long(argc, argv, "c:v", long_options, &optionIndex); if(c == -1) break; @@ -1047,8 +1049,12 @@ int main(int argc, char** argv) break; //Option had arg break; + case 'c': + configLocation = string(optarg); + break; case 'v': versionFlag = 1; + break; case '?': //Error?? break; @@ -1123,16 +1129,19 @@ int main(int argc, char** argv) std::vector<Err> cfgErr; cout << "Registered commands" << endl; - - char* confDir = getenv("XDG_CONFIG_HOME"); - if(confDir != NULL) - { - cfgErr = cfg.loadFromFile(string(confDir) + "/YATwm/config"); - } + + if(configLocation != "") + cfgErr = cfg.loadFromFile(configLocation); else { - string home = getenv("HOME"); - cfgErr = cfg.loadFromFile(home + "/.config/YATwm/config"); + char* confDir = getenv("XDG_CONFIG_HOME"); + if(confDir != NULL) + cfgErr = cfg.loadFromFile(string(confDir) + "/YATwm/config"); + else + { + string home = getenv("HOME"); + cfgErr = cfg.loadFromFile(home + "/.config/YATwm/config"); + } } cout << "Done config" << endl; @@ -1233,7 +1242,6 @@ int main(int argc, char** argv) } if(ready == -1) { - cout << "E" << endl; log("ERROR"); } } |
