1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-25 13:55:47 -05:00
polybar/include/x11/xresources.hpp
Michael Carlberg 1b5979ba10 feat(config): Default reference values
- Add fallback values to env/xrdb references:

  ${env:UNEXISTING:fallback value}
  ${xrdb:UNEXISTING:fallback value}

- Replace ${BAR.key} with ${root.key} and display
  deprecation warning if the former is used
2016-11-18 18:04:24 +01:00

36 lines
774 B
C++

#pragma once
#include <X11/Xresource.h>
#include "common.hpp"
LEMONBUDDY_NS
class xresource_manager {
public:
explicit xresource_manager();
string get_string(string name, string fallback = "") const;
float get_float(string name, float fallback = 0.0f) const;
int get_int(string name, int fallback = 0) const;
protected:
string load_value(string key, string res_type, size_t n) const;
private:
char* m_manager = nullptr;
XrmDatabase m_db;
};
namespace {
/**
* Configure injection module
*/
template <typename T = const xresource_manager&>
di::injector<T> configure_xresource_manager() {
auto instance = factory::generic_singleton<xresource_manager>();
return di::make_injector(di::bind<>().to(instance));
}
}
LEMONBUDDY_NS_END