src/modules/fs.cpp
/**
   * Output content using configured format tags
   */
Output content using configured format tags
Output content using configured format tags
bool fs_module::build(builder* builder, const string& tag) const {
    auto& mount = m_mounts[m_index];
    auto replace_tokens = [&](const label_t& label) {
      label->reset_tokens();
      label->replace_token("%mountpoint%", mount->mountpoint);
      label->replace_token("%type%", mount->type);
      label->replace_token("%fsname%", mount->fsname);
      label->replace_token("%percentage_free%", to_string(mount->percentage_free));
      label->replace_token("%percentage_used%", to_string(mount->percentage_used));
      label->replace_token(
          "%total%", string_util::filesize(mount->bytes_total, m_fixed ? 2 : 0, m_fixed, m_bar.locale));
      label->replace_token("%free%", string_util::filesize(mount->bytes_avail, m_fixed ? 2 : 0, m_fixed, m_bar.locale));
      label->replace_token("%used%", string_util::filesize(mount->bytes_used, m_fixed ? 2 : 0, m_fixed, m_bar.locale));
    };
    if (tag == TAG_BAR_FREE) {
      builder->node(m_barfree->output(mount->percentage_free));
    } else if (tag == TAG_BAR_USED) {
      builder->node(m_barused->output(mount->percentage_used));
    } else if (tag == TAG_RAMP_CAPACITY) {
      builder->node(m_rampcapacity->get_by_percentage_with_borders(mount->percentage_free, 0, m_perc_used_warn));
    } else if (tag == TAG_LABEL_MOUNTED) {
      replace_tokens(m_labelmounted);
      builder->node(m_labelmounted);
    } else if (tag == TAG_LABEL_WARN) {
      replace_tokens(m_labelwarn);
      builder->node(m_labelwarn);
    } else if (tag == TAG_LABEL_UNMOUNTED) {
      m_labelunmounted->reset_tokens();
      m_labelunmounted->replace_token("%mountpoint%", mount->mountpoint);
      builder->node(m_labelunmounted);
    } else {
      return false;
    }
    return true;
  }
bool fs_module :: build ( builder * builder , const string & tag ) const { auto & mount = m_mounts [ m_index ] ; auto replace_tokens = [ & ] ( const label_t & label ) { label -> reset_tokens ( ) ; label -> replace_token ( " " , mount -> mountpoint ) ; label -> replace_token ( " " , mount -> type ) ; label -> replace_token ( " " , mount -> fsname ) ; label -> replace_token ( " " , to_string ( mount -> percentage_free ) ) ; label -> replace_token ( " " , to_string ( mount -> percentage_used ) ) ; label -> replace_token ( " " , string_util :: filesize ( mount -> bytes_total , m_fixed ? 2 : 0 , m_fixed , m_bar . locale ) ) ; label -> replace_token ( " " , string_util :: filesize ( mount -> bytes_avail , m_fixed ? 2 : 0 , m_fixed , m_bar . locale ) ) ; label -> replace_token ( " " , string_util :: filesize ( mount -> bytes_used , m_fixed ? 2 : 0 , m_fixed , m_bar . locale ) ) ; } ; if ( tag == TAG_BAR_FREE ) { builder -> node ( m_barfree -> output ( mount -> percentage_free ) ) ; } else if ( tag == TAG_BAR_USED ) { builder -> node ( m_barused -> output ( mount -> percentage_used ) ) ; } else if ( tag == TAG_RAMP_CAPACITY ) { builder -> node ( m_rampcapacity -> get_by_percentage_with_borders ( mount -> percentage_free , 0 , m_perc_used_warn ) ) ; } else if ( tag == TAG_LABEL_MOUNTED ) { replace_tokens ( m_labelmounted ) ; builder -> node ( m_labelmounted ) ; } else if ( tag == TAG_LABEL_WARN ) { replace_tokens ( m_labelwarn ) ; builder -> node ( m_labelwarn ) ; } else if ( tag == TAG_LABEL_UNMOUNTED ) { m_labelunmounted -> reset_tokens ( ) ; m_labelunmounted -> replace_token ( " " , mount -> mountpoint ) ; builder -> node ( m_labelunmounted ) ; } else { return false ; } return true ; }
Output content using configured format tags
Output content using configured format tags