From 66cd4cd08f7d8910e8a34ac14cb1be7310863106 Mon Sep 17 00:00:00 2001 From: Zaedus Date: Thu, 15 Jul 2021 19:24:16 -0500 Subject: [PATCH 1/2] Implement title default value --- include/modules/dwm.hpp | 6 ++++++ src/modules/dwm.cpp | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/modules/dwm.hpp b/include/modules/dwm.hpp index 67de3d33..a23e1e80 100644 --- a/include/modules/dwm.hpp +++ b/include/modules/dwm.hpp @@ -356,6 +356,12 @@ namespace modules { */ label_t m_title_label; + /** + * The default value displayed when m_title_label is false + */ + + std::string m_title_label_default{"Desktop"}; + /** * Connection to DWM */ diff --git a/src/modules/dwm.cpp b/src/modules/dwm.cpp index 4f0ac7c3..9ced52fe 100644 --- a/src/modules/dwm.cpp +++ b/src/modules/dwm.cpp @@ -46,6 +46,7 @@ namespace modules { m_title_label = load_optional_label(m_conf, name(), "label-title", "%title%"); } + m_title_label_default = m_conf.get(name(), "label-title-default", m_title_label_default); m_tags_click = m_conf.get(name(), "enable-tags-click", m_tags_click); 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); @@ -436,7 +437,7 @@ namespace modules { void dwm_module::update_title_label(const string& title) { m_title_label->reset_tokens(); - m_title_label->replace_token("%title%", title); + m_title_label->replace_token("%title%", title == "" ? m_title_label_default : title ); } void dwm_module::update_title_label() { From e4bd04f5aef1b5b8cb17032ef2f09698f36aac39 Mon Sep 17 00:00:00 2001 From: Zaedus Date: Thu, 15 Jul 2021 20:01:17 -0500 Subject: [PATCH 2/2] Update README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 12c5deca..fb89d94d 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,9 @@ label-title-padding = 2 label-title-foreground = ${colors.primary} label-title-maxlen = 30 +; Defaults to 'Desktop' +label-title-default = "Desktop" + ; Symbol of current layout ; Available tokens: ; %symbol%