mirror of
https://github.com/polybar/polybar.git
synced 2024-12-09 14:10:19 -05:00
fix(bspwm): Remove monitor property
- Use the bar settings stored in the base class. - Add fold markers
This commit is contained in:
parent
fd44bcd8f6
commit
dc2d33ceba
2 changed files with 22 additions and 32 deletions
|
@ -66,7 +66,6 @@ namespace modules {
|
||||||
label_t m_monitorlabel;
|
label_t m_monitorlabel;
|
||||||
iconset_t m_icons;
|
iconset_t m_icons;
|
||||||
bool m_pinworkspaces = true;
|
bool m_pinworkspaces = true;
|
||||||
string m_monitor;
|
|
||||||
unsigned long m_hash;
|
unsigned long m_hash;
|
||||||
|
|
||||||
// used while formatting output
|
// used while formatting output
|
||||||
|
|
|
@ -5,16 +5,14 @@
|
||||||
LEMONBUDDY_NS
|
LEMONBUDDY_NS
|
||||||
|
|
||||||
namespace modules {
|
namespace modules {
|
||||||
void bspwm_module::setup() {
|
void bspwm_module::setup() { // {{{
|
||||||
m_monitor = m_bar.monitor->name;
|
// Create ipc subscriber
|
||||||
|
m_subscriber = bspwm_util::make_subscriber();
|
||||||
// Load configuration values {{{
|
|
||||||
|
|
||||||
|
// Load configuration values
|
||||||
GET_CONFIG_VALUE(name(), m_pinworkspaces, "pin-workspaces");
|
GET_CONFIG_VALUE(name(), m_pinworkspaces, "pin-workspaces");
|
||||||
|
|
||||||
// }}}
|
// Add formats and create components
|
||||||
// Add formats and create components {{{
|
|
||||||
|
|
||||||
m_formatter->add(
|
m_formatter->add(
|
||||||
DEFAULT_FORMAT, TAG_LABEL_STATE, {TAG_LABEL_STATE}, {TAG_LABEL_MONITOR, TAG_LABEL_MODE});
|
DEFAULT_FORMAT, TAG_LABEL_STATE, {TAG_LABEL_STATE}, {TAG_LABEL_MONITOR, TAG_LABEL_MODE});
|
||||||
|
|
||||||
|
@ -62,24 +60,17 @@ namespace modules {
|
||||||
m_icons->add(vec[0], icon_t{new icon{vec[1]}});
|
m_icons->add(vec[0], icon_t{new icon{vec[1]}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} // }}}
|
||||||
|
|
||||||
// }}}
|
void bspwm_module::stop() { // {{{
|
||||||
// Create ipc subscriber {{{
|
|
||||||
|
|
||||||
m_subscriber = bspwm_util::make_subscriber();
|
|
||||||
|
|
||||||
// }}}
|
|
||||||
}
|
|
||||||
|
|
||||||
void bspwm_module::stop() {
|
|
||||||
if (m_subscriber) {
|
if (m_subscriber) {
|
||||||
m_log.info("%s: Disconnecting from socket", name());
|
m_log.info("%s: Disconnecting from socket", name());
|
||||||
m_subscriber->disconnect();
|
m_subscriber->disconnect();
|
||||||
}
|
}
|
||||||
event_module::stop();
|
event_module::stop();
|
||||||
}
|
} // }}}
|
||||||
|
|
||||||
bool bspwm_module::has_event() {
|
bool bspwm_module::has_event() { // {{{
|
||||||
if (m_subscriber->poll(POLLHUP, 0)) {
|
if (m_subscriber->poll(POLLHUP, 0)) {
|
||||||
m_log.warn("%s: Reconnecting to socket...", name());
|
m_log.warn("%s: Reconnecting to socket...", name());
|
||||||
m_subscriber = bspwm_util::make_subscriber();
|
m_subscriber = bspwm_util::make_subscriber();
|
||||||
|
@ -88,9 +79,9 @@ namespace modules {
|
||||||
ssize_t bytes = 0;
|
ssize_t bytes = 0;
|
||||||
m_subscriber->receive(1, bytes, MSG_PEEK);
|
m_subscriber->receive(1, bytes, MSG_PEEK);
|
||||||
return bytes > 0;
|
return bytes > 0;
|
||||||
}
|
} // }}}
|
||||||
|
|
||||||
bool bspwm_module::update() {
|
bool bspwm_module::update() { // {{{
|
||||||
ssize_t bytes = 0;
|
ssize_t bytes = 0;
|
||||||
string data = m_subscriber->receive(BUFSIZ - 1, bytes, 0);
|
string data = m_subscriber->receive(BUFSIZ - 1, bytes, 0);
|
||||||
|
|
||||||
|
@ -124,8 +115,8 @@ namespace modules {
|
||||||
|
|
||||||
// Extract the string for the defined monitor
|
// Extract the string for the defined monitor
|
||||||
if (m_pinworkspaces) {
|
if (m_pinworkspaces) {
|
||||||
const auto needle_active = ":M" + m_monitor + ":";
|
const auto needle_active = ":M" + m_bar.monitor->name + ":";
|
||||||
const auto needle_inactive = ":m" + m_monitor + ":";
|
const auto needle_inactive = ":m" + m_bar.monitor->name + ":";
|
||||||
|
|
||||||
if ((pos = data.find(prefix)) != std::string::npos)
|
if ((pos = data.find(prefix)) != std::string::npos)
|
||||||
data = data.replace(pos, prefix.length(), ":");
|
data = data.replace(pos, prefix.length(), ":");
|
||||||
|
@ -277,9 +268,9 @@ namespace modules {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} // }}}
|
||||||
|
|
||||||
string bspwm_module::get_output() {
|
string bspwm_module::get_output() { // {{{
|
||||||
string output;
|
string output;
|
||||||
for (m_index = 0; m_index < m_monitors.size(); m_index++) {
|
for (m_index = 0; m_index < m_monitors.size(); m_index++) {
|
||||||
if (m_index > 0) {
|
if (m_index > 0) {
|
||||||
|
@ -288,9 +279,9 @@ namespace modules {
|
||||||
output += event_module::get_output();
|
output += event_module::get_output();
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
} // }}}
|
||||||
|
|
||||||
bool bspwm_module::build(builder* builder, string tag) const {
|
bool bspwm_module::build(builder* builder, string tag) const { // {{{
|
||||||
if (tag == TAG_LABEL_MONITOR) {
|
if (tag == TAG_LABEL_MONITOR) {
|
||||||
builder->node(m_monitors[m_index]->label);
|
builder->node(m_monitors[m_index]->label);
|
||||||
return true;
|
return true;
|
||||||
|
@ -325,9 +316,9 @@ namespace modules {
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} // }}}
|
||||||
|
|
||||||
bool bspwm_module::handle_event(string cmd) {
|
bool bspwm_module::handle_event(string cmd) { // {{{
|
||||||
if (cmd.find(EVENT_CLICK) != 0) {
|
if (cmd.find(EVENT_CLICK) != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -356,11 +347,11 @@ namespace modules {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} // }}}
|
||||||
|
|
||||||
bool bspwm_module::receive_events() const {
|
bool bspwm_module::receive_events() const { // {{{
|
||||||
return true;
|
return true;
|
||||||
}
|
} // }}}
|
||||||
}
|
}
|
||||||
|
|
||||||
LEMONBUDDY_NS_END
|
LEMONBUDDY_NS_END
|
||||||
|
|
Loading…
Reference in a new issue