mirror of
https://github.com/polybar/polybar.git
synced 2024-11-18 13:55:11 -05:00
parent
43350c484e
commit
466e9e212f
5 changed files with 38 additions and 8 deletions
|
@ -33,6 +33,16 @@ class config {
|
|||
string build_path(const string& section, const string& key) const;
|
||||
void warn_deprecated(const string& section, const string& key, string replacement) const;
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if a given parameter exists
|
||||
*/
|
||||
template <typename T>
|
||||
bool has(string section, string key) const {
|
||||
auto val = m_ptree.get_optional<T>(build_path(section, key));
|
||||
return (val != boost::none);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parameter for the current bar by name
|
||||
*/
|
||||
|
|
|
@ -73,6 +73,8 @@ namespace drawtypes {
|
|||
|
||||
label_t load_optional_label(const config& conf, string section, string name, string def = "");
|
||||
|
||||
label_t load_either_config_label(const config& conf, string section, string name1, string name2, string def = "");
|
||||
|
||||
icon_t load_icon(const config& conf, string section, string name, bool required = true, string def = "");
|
||||
|
||||
icon_t load_optional_icon(const config& conf, string section, string name, string def = "");
|
||||
|
|
|
@ -12,6 +12,9 @@ namespace modules {
|
|||
WORKSPACE_URGENT,
|
||||
WORKSPACE_EMPTY,
|
||||
WORKSPACE_OCCUPIED,
|
||||
WORKSPACE_FOCUSED_URGENT,
|
||||
WORKSPACE_FOCUSED_EMPTY,
|
||||
WORKSPACE_FOCUSED_OCCUPIED,
|
||||
WORKSPACE_DIMMED, // used when the monitor is out of focus
|
||||
WORKSPACE_DIMMED_ACTIVE,
|
||||
WORKSPACE_DIMMED_URGENT,
|
||||
|
|
|
@ -167,6 +167,13 @@ namespace drawtypes {
|
|||
return load_label(conf, move(section), move(name), false, move(def));
|
||||
}
|
||||
|
||||
label_t load_either_config_label(const config& conf, string section, string name1, string name2, string def) {
|
||||
if (conf.has<string>(section, name1))
|
||||
return load_label(conf, section, name1, true, "");
|
||||
else
|
||||
return load_optional_label(conf, section, name2, def);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an icon by loading values from the configuration
|
||||
*/
|
||||
|
|
|
@ -43,8 +43,16 @@ namespace modules {
|
|||
state_ws::WORKSPACE_OCCUPIED, load_optional_label(m_conf, name(), "label-occupied", DEFAULT_WS_LABEL)));
|
||||
m_statelabels.insert(
|
||||
make_pair(state_ws::WORKSPACE_URGENT, load_optional_label(m_conf, name(), "label-urgent", DEFAULT_WS_LABEL)));
|
||||
m_statelabels.insert(
|
||||
make_pair(state_ws::WORKSPACE_OCCUPIED, load_optional_label(m_conf, name(), "label-occupied", DEFAULT_WS_LABEL)));
|
||||
m_statelabels.insert(
|
||||
make_pair(state_ws::WORKSPACE_EMPTY, load_optional_label(m_conf, name(), "label-empty", DEFAULT_WS_LABEL)));
|
||||
m_statelabels.insert(
|
||||
make_pair(state_ws::WORKSPACE_FOCUSED_OCCUPIED, load_either_config_label(m_conf, name(), "label-focused-occupied", "label-focused", DEFAULT_WS_LABEL)));
|
||||
m_statelabels.insert(
|
||||
make_pair(state_ws::WORKSPACE_FOCUSED_URGENT, load_either_config_label(m_conf, name(), "label-focused-urgent", "label-focused", DEFAULT_WS_LABEL)));
|
||||
m_statelabels.insert(
|
||||
make_pair(state_ws::WORKSPACE_FOCUSED_EMPTY, load_either_config_label(m_conf, name(), "label-focused-empty", "label-focused", DEFAULT_WS_LABEL)));
|
||||
m_statelabels.insert(make_pair(state_ws::WORKSPACE_DIMMED, load_optional_label(m_conf, name(), "label-dimmed")));
|
||||
m_statelabels.insert(
|
||||
make_pair(state_ws::WORKSPACE_DIMMED_ACTIVE, load_optional_label(m_conf, name(), "label-dimmed-active")));
|
||||
|
@ -195,23 +203,23 @@ namespace modules {
|
|||
m_monitors.back()->focused = true;
|
||||
break;
|
||||
case 'F':
|
||||
workspace_flag = state_ws::WORKSPACE_ACTIVE;
|
||||
workspace_flag = state_ws::WORKSPACE_FOCUSED_EMPTY;
|
||||
break;
|
||||
case 'O':
|
||||
workspace_flag = state_ws::WORKSPACE_ACTIVE;
|
||||
workspace_flag = state_ws::WORKSPACE_FOCUSED_OCCUPIED;
|
||||
break;
|
||||
case 'U':
|
||||
workspace_flag = state_ws::WORKSPACE_FOCUSED_URGENT;
|
||||
break;
|
||||
case 'f':
|
||||
workspace_flag = state_ws::WORKSPACE_EMPTY;
|
||||
break;
|
||||
case 'o':
|
||||
workspace_flag = state_ws::WORKSPACE_OCCUPIED;
|
||||
break;
|
||||
case 'U':
|
||||
workspace_flag = state_ws::WORKSPACE_URGENT;
|
||||
break;
|
||||
case 'u':
|
||||
workspace_flag = state_ws::WORKSPACE_URGENT;
|
||||
break;
|
||||
case 'f':
|
||||
workspace_flag = state_ws::WORKSPACE_EMPTY;
|
||||
break;
|
||||
case 'L':
|
||||
switch (value[0]) {
|
||||
case 0:
|
||||
|
|
Loading…
Reference in a new issue