mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2024-11-16 22:25:59 +01:00
Merge pull request #12 from namaenonaimumei/PR_custom-config
feat: Provide way to override default config file path
This commit is contained in:
commit
034a663dbb
3 changed files with 25 additions and 3 deletions
|
@ -34,6 +34,7 @@ public:
|
||||||
std::vector<std::unique_ptr<SMonitor>> m_vMonitors;
|
std::vector<std::unique_ptr<SMonitor>> m_vMonitors;
|
||||||
|
|
||||||
bool m_bIPCEnabled = true;
|
bool m_bIPCEnabled = true;
|
||||||
|
std::string m_szExplicitConfigPath;
|
||||||
|
|
||||||
void removeOldHyprpaperImages();
|
void removeOldHyprpaperImages();
|
||||||
void preloadAllWallpapersFromConfig();
|
void preloadAllWallpapersFromConfig();
|
||||||
|
|
|
@ -4,11 +4,17 @@
|
||||||
CConfigManager::CConfigManager() {
|
CConfigManager::CConfigManager() {
|
||||||
// init the entire thing
|
// init the entire thing
|
||||||
|
|
||||||
const char* const ENVHOME = getenv("HOME");
|
std::string configPath;
|
||||||
const std::string CONFIGPATH = ENVHOME + (std::string) "/.config/hypr/hyprpaper.conf";
|
if (g_pHyprpaper->m_szExplicitConfigPath == "") {
|
||||||
|
const char *const ENVHOME = getenv("HOME");
|
||||||
|
configPath = ENVHOME + (std::string) "/.config/hypr/hyprpaper.conf";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
configPath = g_pHyprpaper->m_szExplicitConfigPath;
|
||||||
|
}
|
||||||
|
|
||||||
std::ifstream ifs;
|
std::ifstream ifs;
|
||||||
ifs.open(CONFIGPATH);
|
ifs.open(configPath);
|
||||||
|
|
||||||
if (!ifs.good()) {
|
if (!ifs.good()) {
|
||||||
Debug::log(CRIT, "Hyprpaper was not provided a config!");
|
Debug::log(CRIT, "Hyprpaper was not provided a config!");
|
||||||
|
|
15
src/main.cpp
15
src/main.cpp
|
@ -5,8 +5,23 @@
|
||||||
int main(int argc, char** argv, char** envp) {
|
int main(int argc, char** argv, char** envp) {
|
||||||
Debug::log(LOG, "Welcome to hyprpaper!\nbuilt from commit %s (%s)", GIT_COMMIT_HASH, GIT_COMMIT_MESSAGE);
|
Debug::log(LOG, "Welcome to hyprpaper!\nbuilt from commit %s (%s)", GIT_COMMIT_HASH, GIT_COMMIT_MESSAGE);
|
||||||
|
|
||||||
|
// parse some args
|
||||||
|
std::string configPath;
|
||||||
|
for (int i = 1; i < argc; ++i) {
|
||||||
|
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());
|
||||||
|
} else {
|
||||||
|
std::cout << "Hyprpaper usage: hyprpaper [arg [...]].\n\nArguments:\n" <<
|
||||||
|
"--help -h | Show this help message\n" <<
|
||||||
|
"--config -c | Specify config file to use\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// starts
|
// starts
|
||||||
g_pHyprpaper = std::make_unique<CHyprpaper>();
|
g_pHyprpaper = std::make_unique<CHyprpaper>();
|
||||||
|
g_pHyprpaper->m_szExplicitConfigPath = configPath;
|
||||||
g_pHyprpaper->init();
|
g_pHyprpaper->init();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue