summaryrefslogtreecommitdiff
path: root/config.h
diff options
context:
space:
mode:
authorBossCode45 <human.cyborg42@gmail.com>2023-06-19 12:49:19 +1200
committerBossCode45 <human.cyborg42@gmail.com>2023-06-19 12:49:19 +1200
commit8b4b487e685c72a478baf74aea2bf756988fe550 (patch)
tree9a5ac8ffbd65942f4ce0117a5316f7db7f4eb918 /config.h
parent6655d5dfb24ca3fd36b02550c526bca1f5d924e9 (diff)
parent185015b39b8db953b8034f29724ef03de09e7ea1 (diff)
downloadYATwm-8b4b487e685c72a478baf74aea2bf756988fe550.tar.gz
YATwm-8b4b487e685c72a478baf74aea2bf756988fe550.zip
Merge branch 'config-refactor'
Merging in the new config system with commands
Diffstat (limited to 'config.h')
-rw-r--r--config.h118
1 files changed, 39 insertions, 79 deletions
diff --git a/config.h b/config.h
index 31005e7..452db9c 100644
--- a/config.h
+++ b/config.h
@@ -1,93 +1,53 @@
#pragma once
-#include "error.h"
-
-#include <toml++/toml.hpp>
-
+#include "commands.h"
#include <X11/X.h>
#include <X11/keysym.h>
#include <string>
+#include <vector>
-enum MoveDir
-{
- Up,
- Right,
- Down,
- Left
-};
-
-typedef union
-{
- char* str;
- int num;
- MoveDir dir;
-} KeyArg;
-
-struct KeyBind
+struct Workspace
{
- unsigned int modifiers;
- KeySym keysym;
- void(* func) (const KeyArg arg);
- KeyArg args;
+ std::string name;
+ int* screenPreferences;
+ int screenPreferencesc;
};
-//Keybind commands
-#define KEYCOM(X) \
- void X (const KeyArg arg)
-KEYCOM(exit);
-KEYCOM(spawn);
-KEYCOM(toggle);
-KEYCOM(kill);
-KEYCOM(changeWS);
-KEYCOM(wToWS);
-KEYCOM(focChange);
-KEYCOM(wMove);
-KEYCOM(bashSpawn);
-KEYCOM(reload);
-KEYCOM(wsDump);
-KEYCOM(nextMonitor);
+#define COMMAND(X) \
+ const void X (const CommandArg* argv)
class Config
-{
- public:
- Config();
- ~Config();
- void free();
+{
+public:
+ Config(CommandsModule& commandsModule);
+ ~Config();
+ void free();
- Err loadFromFile(std::string path);
- Err reload();
-
- // Startup
- std::string* startupBash;
- int startupBashc;
-
- // Main
- int gaps;
- int outerGaps;
- std::string logFile;
-
- // Workspaces
- int numWS;
- std::string* workspaceNames;
- int workspaceNamesc;
- int maxMonitors;
- int** screenPreferences;
- int screenPreferencesc;
-
- // Keybinds
- KeyBind* binds;
- int bindsc;
- private:
- template <typename T>
- T getValue(std::string path, Err* err);
-
- void loadWorkspaceArrays(toml::table tbl, toml::table defaults, Err* err);
- void loadStartupBash(toml::table tbl, toml::table defaults, Err* err);
-
- toml::table tbl;
- toml::table defaults;
-
- bool loaded = false;
- std::string path;
+ std::vector<Err> loadFromFile(std::string path);
+ std::vector<Err> reloadFile();
+
+ // Main
+ int gaps;
+ int outerGaps;
+ std::string logFile;
+
+ // Workspaces
+ std::vector<Workspace> workspaces;
+ int numWS;
+ bool loaded = false;
+
+ // Binds
+ bool swapSuperAlt;
+
+ // Config Commands
+ COMMAND(gapsCmd);
+ COMMAND(outerGapsCmd);
+ COMMAND(logFileCmd);
+ COMMAND(addWorkspaceCmd);
+ COMMAND(swapSuperAltCmd);
+
+private:
+ CommandsModule& commandsModule;
+ std::string file;
};