diff --git a/config.cmake b/config.cmake index 7ad14ffc..0846b4c5 100644 --- a/config.cmake +++ b/config.cmake @@ -174,6 +174,7 @@ enable-tags-click = false enable-layout-click = false enable-layout-scroll = false layout-scroll-wrap = false +layout-scroll-reverse = false ; If enable-layout-click = true, clicking the layout symbol will switch to this layout secondary-layout-symbol = [M] diff --git a/include/modules/dwm.hpp b/include/modules/dwm.hpp index 1b86de27..e0533655 100644 --- a/include/modules/dwm.hpp +++ b/include/modules/dwm.hpp @@ -258,6 +258,11 @@ namespace modules { */ bool m_layout_wrap{true}; + /** + * If true, scrolling the layout will cycle layouts in the reverse direction + */ + bool m_layout_reverse{false}; + /** * If the layout symbol is clicked on, it will set the layout represented by * this symbol. The default is monocle mode [M]. diff --git a/src/modules/dwm.cpp b/src/modules/dwm.cpp index 2ee041a1..02639705 100644 --- a/src/modules/dwm.cpp +++ b/src/modules/dwm.cpp @@ -58,6 +58,7 @@ namespace modules { m_layout_click = m_conf.get(name(), "enable-layout-click", m_layout_click); m_layout_scroll = m_conf.get(name(), "enable-layout-scroll", m_layout_scroll); m_layout_wrap = m_conf.get(name(), "layout-scroll-wrap", m_layout_wrap); + m_layout_reverse = m_conf.get(name(), "layout-scroll-reverse", m_layout_reverse); m_secondary_layout_symbol = m_conf.get(name(), "secondary-layout-symbol", m_secondary_layout_symbol); try { @@ -164,8 +165,13 @@ namespace modules { if (m_layout_scroll) { auto addr_next = next_layout(*m_current_layout, m_layout_wrap)->address; auto addr_prev = prev_layout(*m_current_layout, m_layout_wrap)->address; - builder->cmd(mousebtn::SCROLL_DOWN, build_cmd(EVENT_LAYOUT_SDOWN, to_string(addr_prev))); - builder->cmd(mousebtn::SCROLL_UP, build_cmd(EVENT_LAYOUT_SUP, to_string(addr_next))); + if (m_layout_reverse) { + builder->cmd(mousebtn::SCROLL_DOWN, build_cmd(EVENT_LAYOUT_SDOWN, to_string(addr_prev))); + builder->cmd(mousebtn::SCROLL_UP, build_cmd(EVENT_LAYOUT_SUP, to_string(addr_next))); + } else { + builder->cmd(mousebtn::SCROLL_DOWN, build_cmd(EVENT_LAYOUT_SDOWN, to_string(addr_next))); + builder->cmd(mousebtn::SCROLL_UP, build_cmd(EVENT_LAYOUT_SUP, to_string(addr_prev))); + } } builder->node(m_layout_label); if (m_layout_click) {