2016-05-31 03:58:58 +00:00
|
|
|
#pragma once
|
2016-05-19 14:41:06 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <memory>
|
2016-06-23 20:26:19 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <sstream>
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-05-24 04:30:06 +00:00
|
|
|
#include "config.hpp"
|
2016-05-19 14:41:06 +00:00
|
|
|
#include "exception.hpp"
|
2016-06-23 20:26:19 +00:00
|
|
|
#include "utils/xcb.hpp"
|
2016-05-19 14:41:06 +00:00
|
|
|
|
|
|
|
DefineBaseException(ConfigurationError);
|
|
|
|
|
2016-05-24 04:30:06 +00:00
|
|
|
struct CompiledWithoutModuleSupport : public ConfigurationError
|
|
|
|
{
|
2016-05-31 03:58:58 +00:00
|
|
|
explicit CompiledWithoutModuleSupport(std::string module_name)
|
2016-05-24 04:30:06 +00:00
|
|
|
: ConfigurationError(std::string(APP_NAME) + " was not compiled with support for module \""+ module_name +"\"") {}
|
|
|
|
};
|
|
|
|
|
2016-05-19 14:41:06 +00:00
|
|
|
struct Font
|
|
|
|
{
|
|
|
|
std::string id;
|
|
|
|
int offset;
|
|
|
|
|
2016-06-21 01:59:43 +00:00
|
|
|
Font(std::string id, int offset)
|
2016-05-19 14:41:06 +00:00
|
|
|
: id(id), offset(offset){}
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Cmd
|
|
|
|
{
|
|
|
|
LEFT_CLICK = 1,
|
|
|
|
MIDDLE_CLICK = 2,
|
|
|
|
RIGHT_CLICK = 3,
|
|
|
|
SCROLL_UP = 4,
|
|
|
|
SCROLL_DOWN = 5,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Options
|
|
|
|
{
|
2016-06-23 20:26:19 +00:00
|
|
|
std::shared_ptr<xcb::monitor_t> monitor;
|
|
|
|
|
2016-05-19 14:41:06 +00:00
|
|
|
std::string wm_name;
|
|
|
|
std::string locale;
|
|
|
|
|
|
|
|
std::string background = "#ffffff";
|
|
|
|
std::string foreground = "#000000";
|
|
|
|
std::string linecolor = "#000000";
|
|
|
|
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
|
|
|
|
int offset_x = 0;
|
|
|
|
int offset_y = 0;
|
|
|
|
|
|
|
|
bool bottom = false;
|
|
|
|
bool dock = true;
|
|
|
|
int clickareas = 25;
|
|
|
|
|
|
|
|
std::string separator;
|
|
|
|
int spacing = 1;
|
|
|
|
int lineheight = 1;
|
|
|
|
|
|
|
|
int padding_left = 0;
|
|
|
|
int padding_right = 0;
|
|
|
|
int module_margin_left = 0;
|
|
|
|
int module_margin_right = 2;
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<Font>> fonts;
|
|
|
|
|
|
|
|
std::string get_geom()
|
|
|
|
{
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << this->width << "x" << this->height << "+";
|
|
|
|
ss << this->offset_x << "+" << this->offset_y;
|
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class Bar
|
|
|
|
{
|
|
|
|
std::string config_path;
|
|
|
|
|
|
|
|
std::vector<std::string> mod_left;
|
|
|
|
std::vector<std::string> mod_center;
|
|
|
|
std::vector<std::string> mod_right;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Bar();
|
|
|
|
|
|
|
|
std::unique_ptr<Options> opts;
|
|
|
|
|
|
|
|
std::string get_output();
|
|
|
|
std::string get_exec_line();
|
|
|
|
|
|
|
|
void load();
|
|
|
|
};
|
|
|
|
|
|
|
|
std::shared_ptr<Bar> &get_bar();
|
|
|
|
|
|
|
|
const Options& bar_opts();
|