feat(conf): Option to always show urgent workspaces in i3 (#2378)

When `pin-workspaces` is set to true using `show-urgent` will show
urgent workspaces on the bar even when the workspace is not associated
with the current monitor.
This commit is contained in:
zappolowski 2021-02-15 21:31:34 +01:00 committed by GitHub
parent 50f127f1bc
commit 99900323b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 4 deletions

View File

@ -50,6 +50,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
repository. repository.
### Added ### Added
- Option to always show urgent windows in i3 module when `pin-workspace` is active
([`2374`](https://github.com/polybar/polybar/issues/2374))
- `internal/xworkspaces`: `reverse-scroll` can be used to reverse the scroll - `internal/xworkspaces`: `reverse-scroll` can be used to reverse the scroll
direction when cycling through desktops. direction when cycling through desktops.
- The backslash escape character (\\). - The backslash escape character (\\).

View File

@ -93,6 +93,7 @@ namespace modules {
bool m_wrap{true}; bool m_wrap{true};
bool m_indexsort{false}; bool m_indexsort{false};
bool m_pinworkspaces{false}; bool m_pinworkspaces{false};
bool m_show_urgent{false};
bool m_strip_wsnumbers{false}; bool m_strip_wsnumbers{false};
bool m_fuzzy_match{false}; bool m_fuzzy_match{false};

View File

@ -15,7 +15,7 @@ namespace i3_util {
const auto ws_numsort = [](shared_ptr<workspace_t> a, shared_ptr<workspace_t> b) { return a->num < b->num; }; const auto ws_numsort = [](shared_ptr<workspace_t> a, shared_ptr<workspace_t> b) { return a->num < b->num; };
vector<shared_ptr<workspace_t>> workspaces(const connection_t& conn, const string& output = ""); vector<shared_ptr<workspace_t>> workspaces(const connection_t& conn, const string& output = "", const bool show_urgent = false);
shared_ptr<workspace_t> focused_workspace(const connection_t&); shared_ptr<workspace_t> focused_workspace(const connection_t&);
vector<xcb_window_t> root_windows(connection& conn, const string& output_name = ""); vector<xcb_window_t> root_windows(connection& conn, const string& output_name = "");

View File

@ -33,6 +33,7 @@ namespace modules {
m_wrap = m_conf.get(name(), "wrapping-scroll", m_wrap); m_wrap = m_conf.get(name(), "wrapping-scroll", m_wrap);
m_indexsort = m_conf.get(name(), "index-sort", m_indexsort); m_indexsort = m_conf.get(name(), "index-sort", m_indexsort);
m_pinworkspaces = m_conf.get(name(), "pin-workspaces", m_pinworkspaces); m_pinworkspaces = m_conf.get(name(), "pin-workspaces", m_pinworkspaces);
m_show_urgent = m_conf.get(name(), "show-urgent", m_show_urgent);
m_strip_wsnumbers = m_conf.get(name(), "strip-wsnumbers", m_strip_wsnumbers); m_strip_wsnumbers = m_conf.get(name(), "strip-wsnumbers", m_strip_wsnumbers);
m_fuzzy_match = m_conf.get(name(), "fuzzy-match", m_fuzzy_match); m_fuzzy_match = m_conf.get(name(), "fuzzy-match", m_fuzzy_match);
@ -132,7 +133,7 @@ namespace modules {
vector<shared_ptr<i3_util::workspace_t>> workspaces; vector<shared_ptr<i3_util::workspace_t>> workspaces;
if (m_pinworkspaces) { if (m_pinworkspaces) {
workspaces = i3_util::workspaces(ipc, m_bar.monitor->name); workspaces = i3_util::workspaces(ipc, m_bar.monitor->name, m_show_urgent);
} else { } else {
workspaces = i3_util::workspaces(ipc); workspaces = i3_util::workspaces(ipc);
} }

View File

@ -16,10 +16,10 @@ namespace i3_util {
/** /**
* Get all workspaces for given output * Get all workspaces for given output
*/ */
vector<shared_ptr<workspace_t>> workspaces(const connection_t& conn, const string& output) { vector<shared_ptr<workspace_t>> workspaces(const connection_t& conn, const string& output, const bool show_urgent) {
vector<shared_ptr<workspace_t>> result; vector<shared_ptr<workspace_t>> result;
for (auto&& ws : conn.get_workspaces()) { for (auto&& ws : conn.get_workspaces()) {
if (output.empty() || ws->output == output) { if (output.empty() || ws->output == output || (show_urgent && ws->urgent)) {
result.emplace_back(forward<decltype(ws)>(ws)); result.emplace_back(forward<decltype(ws)>(ws));
} }
} }