Merge pull request #29 from Zaedus/master

Add default option for title label
This commit is contained in:
Mihir Lad 2021-07-19 23:16:22 -04:00 committed by GitHub
commit a0e9d48d77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -172,6 +172,9 @@ label-title-padding = 2
label-title-foreground = ${colors.primary} label-title-foreground = ${colors.primary}
label-title-maxlen = 30 label-title-maxlen = 30
; Defaults to 'Desktop'
label-title-default = "Desktop"
; Symbol of current layout ; Symbol of current layout
; Available tokens: ; Available tokens:
; %symbol% ; %symbol%

View File

@ -356,6 +356,12 @@ namespace modules {
*/ */
label_t m_title_label; 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 * Connection to DWM
*/ */

View File

@ -46,6 +46,7 @@ namespace modules {
m_title_label = load_optional_label(m_conf, name(), "label-title", "%title%"); 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_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_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_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) { void dwm_module::update_title_label(const string& title) {
m_title_label->reset_tokens(); 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() { void dwm_module::update_title_label() {