From f7ca0146ba7fed288c34040db0c2eae1683cf461 Mon Sep 17 00:00:00 2001 From: BossCode45 Date: Wed, 21 Dec 2022 17:25:20 +1300 Subject: Config file working - more tests and potentially features before merge with main though --- config.cpp | 59 +++++++++++++++++++---------------------------------------- 1 file changed, 19 insertions(+), 40 deletions(-) (limited to 'config.cpp') diff --git a/config.cpp b/config.cpp index 097287c..5934f21 100644 --- a/config.cpp +++ b/config.cpp @@ -1,5 +1,7 @@ #include "config.h" +#include "util.h" + #include #include @@ -15,38 +17,19 @@ using std::map, std::string; // For testing using std::cout, std::endl, std::cerr; -void exit(const KeyArg arg) -{ - cout << "exit called" << endl; -} -void spawn(const KeyArg arg) -{ - cout << "spawn called " << arg.str << endl; -} -void changeWS(const KeyArg arg) -{ - cout << "changeWS called" << endl; -} -void wToWS(const KeyArg arg) -{ - cout << "wToWS called" << endl; -} -void focChange(const KeyArg arg) -{ - cout << "focChange called" << endl; -} -void reload(const KeyArg arg) -{ - cout << "reload called" << endl; -} - map funcNameMap = { {"exit", exit}, {"spawn", spawn}, + {"toggle", toggle}, + {"kill", kill}, {"changeWS", changeWS}, {"wToWS", wToWS}, {"focChange", focChange}, - {"reload", reload} + {"wMove", wMove}, + {"bashSpawn", bashSpawn}, + {"reload", reload}, + {"wsDump", wsDump}, + {"nextMonitor", nextMonitor}, }; @@ -54,18 +37,6 @@ Config::Config() { } -std::vector split (const string &s, char delim) { - std::vector result; - std::stringstream ss (s); - string item; - - while (getline (ss, item, delim)) { - result.push_back (item); - } - - return result; -} - void Config::loadFromFile(string path) { //free(); @@ -144,22 +115,30 @@ void Config::loadFromFile(string path) } //Keybinds + bool swapSuperAlt = tbl["Keybinds"]["swapSuperAlt"].value_or(false); bindsc = tbl["Keybinds"]["key"].as_array()->size(); binds = new KeyBind[bindsc]; for(int i = 0; i < bindsc; i++) { KeyBind bind; + bind.modifiers = 0; const string bindString = *tbl["Keybinds"]["key"][i]["bind"].value(); std::vector keys = split(bindString, '+'); for(string key : keys) { if(key == "mod") { - bind.modifiers |= Mod4Mask; + if(!swapSuperAlt) + bind.modifiers |= Mod4Mask; + else + bind.modifiers |= Mod1Mask; } else if(key == "alt") { - bind.modifiers |= Mod1Mask; + if(swapSuperAlt) + bind.modifiers |= Mod4Mask; + else + bind.modifiers |= Mod1Mask; } else if(key == "shift") { -- cgit v1.2.3