|
|
|
@ -3,11 +3,12 @@ |
|
|
|
#include "logging.h" |
|
|
|
#include "logging.h" |
|
|
|
#include <fstream> |
|
|
|
#include <fstream> |
|
|
|
#include <string> |
|
|
|
#include <string> |
|
|
|
|
|
|
|
#include <exception> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MainConfig::MainConfig() { |
|
|
|
MainConfig::MainConfig() { |
|
|
|
INFO("Reading config file"); |
|
|
|
INFO("Reading config file"); |
|
|
|
std::string path(getenv("HOME")); // TODO WINDOWS
|
|
|
|
boost::property_tree::json_parser::read_json(Singleton::config_dir() + "config.json", cfg_); |
|
|
|
boost::property_tree::json_parser::read_json(path + "/.juci/config/config.json", cfg_); |
|
|
|
|
|
|
|
INFO("Config file read"); |
|
|
|
INFO("Config file read"); |
|
|
|
GenerateSource(); |
|
|
|
GenerateSource(); |
|
|
|
GenerateKeybindings(); |
|
|
|
GenerateKeybindings(); |
|
|
|
@ -75,11 +76,15 @@ void MainConfig::GenerateTerminalCommands() { |
|
|
|
|
|
|
|
|
|
|
|
void MainConfig::GenerateKeybindings() { |
|
|
|
void MainConfig::GenerateKeybindings() { |
|
|
|
auto menu = Singleton::menu(); |
|
|
|
auto menu = Singleton::menu(); |
|
|
|
DEBUG("Fetching keybindings"); |
|
|
|
boost::filesystem::path path(Singleton::config_dir() + "menu.xml"); |
|
|
|
|
|
|
|
if (!boost::filesystem::is_regular_file(path)) { |
|
|
|
|
|
|
|
std::cerr << "menu.xml not found" << std::endl; |
|
|
|
|
|
|
|
throw; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::ifstream input(path.string()); |
|
|
|
std::string line; |
|
|
|
std::string line; |
|
|
|
std::ifstream menu_xml("menu.xml"); |
|
|
|
if (input.is_open()) { |
|
|
|
if (menu_xml.is_open()) { |
|
|
|
while (getline(input, line)) |
|
|
|
while (getline(menu_xml, line)) |
|
|
|
|
|
|
|
menu->ui += line; |
|
|
|
menu->ui += line; |
|
|
|
} |
|
|
|
} |
|
|
|
boost::property_tree::ptree keys_json = cfg_.get_child("keybindings"); |
|
|
|
boost::property_tree::ptree keys_json = cfg_.get_child("keybindings"); |
|
|
|
|