From 6ee58399a99fd9ab95b84a8e43698a63f6e99146 Mon Sep 17 00:00:00 2001 From: intexisty <30681593+intexisty@users.noreply.github.com> Date: Wed, 15 Dec 2021 11:43:55 -0600 Subject: [PATCH] Misc config changes, added simple autostart --- include/config/config.h | 4 +++- src/main.cpp | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/config/config.h b/include/config/config.h index 287d4d3..1a5e063 100644 --- a/include/config/config.h +++ b/include/config/config.h @@ -9,10 +9,12 @@ class Config { public: ProgramsConfig programs; + std::string path; Config(const std::string& config_path) { - toml::value toml = toml::parse(config_path); + this->path = config_path; + toml::value toml = toml::parse(path + "config.toml"); programs = ProgramsConfig(toml["Programs"]); } }; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index fda32a3..844e3fc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -10,14 +11,16 @@ #include "xdg.hpp" +void autostart(Config conf); + int main() { #ifndef __DEBUG__ - Config config("config.toml"); + Config config(std::filesystem::canonical("./")); #else std::string path = xdg::ConfigHomeDir(); - path += "/swm/config.toml"; - Config config(path); + path += "/swm/"; + Config config(std::filesystem::canonical(path)); #endif // Check if X is running @@ -50,4 +53,11 @@ int main() { xcb_disconnect(connection); return 0; +} + +// I stole this from a DWM patch, There has got to be a better way to do this! +void autostart(Config conf) { + // The & daemonizes the shell script, we need this unless we want to be blocked from starting + std::string autostart_command = "cd " + conf.path + "; sh ./autostart.sh &"; + system(autostart_command.c_str()); } \ No newline at end of file