From 99900323b786a855228156d3247634084fdcfc3d Mon Sep 17 00:00:00 2001 From: zappolowski Date: Mon, 15 Feb 2021 21:31:34 +0100 Subject: [PATCH] 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. --- CHANGELOG.md | 2 ++ include/modules/i3.hpp | 1 + include/utils/i3.hpp | 2 +- src/modules/i3.cpp | 3 ++- src/utils/i3.cpp | 4 ++-- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5ee0ae8..4b91b88f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 repository. ### 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 direction when cycling through desktops. - The backslash escape character (\\). diff --git a/include/modules/i3.hpp b/include/modules/i3.hpp index 6775169b..c6a10b2d 100644 --- a/include/modules/i3.hpp +++ b/include/modules/i3.hpp @@ -93,6 +93,7 @@ namespace modules { bool m_wrap{true}; bool m_indexsort{false}; bool m_pinworkspaces{false}; + bool m_show_urgent{false}; bool m_strip_wsnumbers{false}; bool m_fuzzy_match{false}; diff --git a/include/utils/i3.hpp b/include/utils/i3.hpp index ae9f2e9d..9ce255c9 100644 --- a/include/utils/i3.hpp +++ b/include/utils/i3.hpp @@ -15,7 +15,7 @@ namespace i3_util { const auto ws_numsort = [](shared_ptr a, shared_ptr b) { return a->num < b->num; }; - vector> workspaces(const connection_t& conn, const string& output = ""); + vector> workspaces(const connection_t& conn, const string& output = "", const bool show_urgent = false); shared_ptr focused_workspace(const connection_t&); vector root_windows(connection& conn, const string& output_name = ""); diff --git a/src/modules/i3.cpp b/src/modules/i3.cpp index 018580a8..7dcd0f29 100644 --- a/src/modules/i3.cpp +++ b/src/modules/i3.cpp @@ -33,6 +33,7 @@ namespace modules { m_wrap = m_conf.get(name(), "wrapping-scroll", m_wrap); m_indexsort = m_conf.get(name(), "index-sort", m_indexsort); 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_fuzzy_match = m_conf.get(name(), "fuzzy-match", m_fuzzy_match); @@ -132,7 +133,7 @@ namespace modules { vector> workspaces; 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 { workspaces = i3_util::workspaces(ipc); } diff --git a/src/utils/i3.cpp b/src/utils/i3.cpp index d78f2fb2..01ee68dc 100644 --- a/src/utils/i3.cpp +++ b/src/utils/i3.cpp @@ -16,10 +16,10 @@ namespace i3_util { /** * Get all workspaces for given output */ - vector> workspaces(const connection_t& conn, const string& output) { + vector> workspaces(const connection_t& conn, const string& output, const bool show_urgent) { vector> result; 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(ws)); } }