mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2024-12-22 04:19:47 +01:00
Add support for --config|-c
This commit is contained in:
parent
3f425d81cb
commit
7c3108327b
3 changed files with 24 additions and 2 deletions
|
@ -34,6 +34,7 @@ public:
|
|||
std::vector<std::unique_ptr<SMonitor>> m_vMonitors;
|
||||
|
||||
bool m_bIPCEnabled = true;
|
||||
std::string explicitConfigPath;
|
||||
|
||||
void removeOldHyprpaperImages();
|
||||
void preloadAllWallpapersFromConfig();
|
||||
|
|
|
@ -4,8 +4,14 @@
|
|||
CConfigManager::CConfigManager() {
|
||||
// init the entire thing
|
||||
|
||||
const char* const ENVHOME = getenv("HOME");
|
||||
const std::string CONFIGPATH = ENVHOME + (std::string) "/.config/hypr/hyprpaper.conf";
|
||||
std::string CONFIGPATH;
|
||||
if (g_pHyprpaper->explicitConfigPath == "") {
|
||||
const char *const ENVHOME = getenv("HOME");
|
||||
CONFIGPATH = ENVHOME + (std::string) "/.config/hypr/hyprpaper.conf";
|
||||
}
|
||||
else {
|
||||
CONFIGPATH = g_pHyprpaper->explicitConfigPath;
|
||||
}
|
||||
|
||||
std::ifstream ifs;
|
||||
ifs.open(CONFIGPATH);
|
||||
|
|
15
src/main.cpp
15
src/main.cpp
|
@ -5,8 +5,23 @@
|
|||
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);
|
||||
|
||||
// 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
|
||||
g_pHyprpaper = std::make_unique<CHyprpaper>();
|
||||
g_pHyprpaper->explicitConfigPath = configPath;
|
||||
g_pHyprpaper->init();
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue