Misc config changes, added simple autostart

This commit is contained in:
intexisty 2021-12-15 11:43:55 -06:00
parent 87ae18459f
commit 6ee58399a9
2 changed files with 16 additions and 4 deletions

View File

@ -9,10 +9,12 @@
class Config { class Config {
public: public:
ProgramsConfig programs; ProgramsConfig programs;
std::string path;
Config(const std::string& config_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"]); programs = ProgramsConfig(toml["Programs"]);
} }
}; };

View File

@ -1,3 +1,4 @@
#include <filesystem>
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -10,14 +11,16 @@
#include "xdg.hpp" #include "xdg.hpp"
void autostart(Config conf);
int main() { int main() {
#ifndef __DEBUG__ #ifndef __DEBUG__
Config config("config.toml"); Config config(std::filesystem::canonical("./"));
#else #else
std::string path = xdg::ConfigHomeDir(); std::string path = xdg::ConfigHomeDir();
path += "/swm/config.toml"; path += "/swm/";
Config config(path); Config config(std::filesystem::canonical(path));
#endif #endif
// Check if X is running // Check if X is running
@ -51,3 +54,10 @@ int main() {
return 0; 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());
}