mirror of
https://github.com/polybar/polybar.git
synced 2024-10-27 05:23:39 -04:00
parent
374ad655ae
commit
90d1fff4e2
3 changed files with 13 additions and 10 deletions
|
@ -23,7 +23,7 @@ class config {
|
|||
using make_type = const config&;
|
||||
static make_type make(string path = "", string bar = "");
|
||||
|
||||
explicit config(const logger& logger, string&& path = "", string&& bar = "");
|
||||
explicit config(const logger& logger, unique_ptr<xresource_manager>&& xrm, string&& path = "", string&& bar = "");
|
||||
|
||||
string filepath() const;
|
||||
string section() const;
|
||||
|
@ -282,14 +282,13 @@ class config {
|
|||
*/
|
||||
template <typename T>
|
||||
T dereference_xrdb(string var, const T& fallback) const {
|
||||
const auto& xrm = xresource_manager::make();
|
||||
size_t pos;
|
||||
|
||||
if ((pos = var.find(":")) != string::npos) {
|
||||
return convert<T>(xrm->get_string(var.substr(0, pos), var.substr(pos + 1)));
|
||||
return convert<T>(m_xrm->get_string(var.substr(0, pos), var.substr(pos + 1)));
|
||||
}
|
||||
|
||||
string str{xrm->get_string(var, "")};
|
||||
string str{m_xrm->get_string(var, "")};
|
||||
return str.empty() ? fallback : convert<T>(move(str));
|
||||
}
|
||||
|
||||
|
@ -310,8 +309,8 @@ class config {
|
|||
|
||||
private:
|
||||
static constexpr const char* KEY_INHERIT{"inherit"};
|
||||
|
||||
const logger& m_log;
|
||||
unique_ptr<xresource_manager> m_xrm;
|
||||
string m_file;
|
||||
string m_barname;
|
||||
sectionmap_t m_sections{};
|
||||
|
|
|
@ -15,15 +15,18 @@ POLYBAR_NS
|
|||
* Create instance
|
||||
*/
|
||||
config::make_type config::make(string path, string bar) {
|
||||
return static_cast<config::make_type>(
|
||||
*factory_util::singleton<std::remove_reference_t<config::make_type>>(logger::make(), move(path), move(bar)));
|
||||
return static_cast<config::make_type>(*factory_util::singleton<std::remove_reference_t<config::make_type>>(
|
||||
logger::make(), xresource_manager::make(), move(path), move(bar)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct config object
|
||||
*/
|
||||
config::config(const logger& logger, string&& path, string&& bar)
|
||||
: m_log(logger), m_file(forward<string>(path)), m_barname(forward<string>(bar)) {
|
||||
config::config(const logger& logger, unique_ptr<xresource_manager>&& xrm, string&& path, string&& bar)
|
||||
: m_log(logger)
|
||||
, m_xrm(forward<decltype(xrm)>(xrm))
|
||||
, m_file(forward<string>(path))
|
||||
, m_barname(forward<string>(bar)) {
|
||||
if (!file_util::exists(m_file)) {
|
||||
throw application_error("Could not find config file: " + m_file);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "x11/winspec.hpp"
|
||||
#include "x11/wm.hpp"
|
||||
#include "x11/xembed.hpp"
|
||||
#include "x11/xresources.hpp"
|
||||
|
||||
// ====================================================================================================
|
||||
//
|
||||
|
@ -62,7 +63,7 @@ tray_manager::~tray_manager() {
|
|||
}
|
||||
|
||||
void tray_manager::setup(const bar_settings& bar_opts) {
|
||||
auto conf = config::make();
|
||||
auto& conf = config::make();
|
||||
auto bs = conf.section();
|
||||
string position;
|
||||
|
||||
|
|
Loading…
Reference in a new issue