1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-18 13:55:11 -05:00

feat(bspwm): Separate focused/unfocused states

Closes #201
This commit is contained in:
Franklin Delehelle 2016-11-29 15:53:32 +01:00 committed by Michael Carlberg
parent 43350c484e
commit 466e9e212f
5 changed files with 38 additions and 8 deletions

View file

@ -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
*/

View file

@ -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 = "");

View file

@ -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,

View file

@ -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
*/

View file

@ -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: