src/modules/fs.cpp
/**
   * Bootstrap the module by reading config values and
   * setting up required components
   */
Bootstrap the module by reading config values and
setting up required components
Bootstrap the module by reading config values and setting up required components
fs_module::fs_module(const bar_settings& bar, string name_) : timer_module<fs_module>(bar, move(name_)) {
    m_mountpoints = m_conf.get_list(name(), "mount");
    m_remove_unmounted = m_conf.get(name(), "remove-unmounted", m_remove_unmounted);
    m_perc_used_warn = m_conf.get(name(), "warn-percentage", 90);
    m_fixed = m_conf.get(name(), "fixed-values", m_fixed);
    m_spacing = m_conf.get(name(), "spacing", m_spacing);
    set_interval(30s);
    m_formatter->add(
        FORMAT_MOUNTED, TAG_LABEL_MOUNTED, {TAG_LABEL_MOUNTED, TAG_BAR_FREE, TAG_BAR_USED, TAG_RAMP_CAPACITY});
    m_formatter->add_optional(FORMAT_WARN, {TAG_LABEL_WARN, TAG_BAR_FREE, TAG_BAR_USED, TAG_RAMP_CAPACITY});
    m_formatter->add(FORMAT_UNMOUNTED, TAG_LABEL_UNMOUNTED, {TAG_LABEL_UNMOUNTED});
    if (m_formatter->has(TAG_LABEL_MOUNTED)) {
      m_labelmounted = load_optional_label(m_conf, name(), TAG_LABEL_MOUNTED, "%mountpoint% %percentage_free%%");
    }
    if (m_formatter->has(TAG_LABEL_WARN)) {
      m_labelwarn = load_optional_label(m_conf, name(), TAG_LABEL_WARN, "%mountpoint% %percentage_free%%");
    }
    if (m_formatter->has(TAG_LABEL_UNMOUNTED)) {
      m_labelunmounted = load_optional_label(m_conf, name(), TAG_LABEL_UNMOUNTED, "%mountpoint% is not mounted");
    }
    if (m_formatter->has(TAG_BAR_FREE)) {
      m_barfree = load_progressbar(m_bar, m_conf, name(), TAG_BAR_FREE);
    }
    if (m_formatter->has(TAG_BAR_USED)) {
      m_barused = load_progressbar(m_bar, m_conf, name(), TAG_BAR_USED);
    }
    if (m_formatter->has(TAG_RAMP_CAPACITY)) {
      m_rampcapacity = load_ramp(m_conf, name(), TAG_RAMP_CAPACITY);
    }
    if (m_formatter->has(TAG_LABEL_UNMOUNTED) && m_remove_unmounted) {
      m_log.warn("%s: Defined format tag \"%s\" will never be used (reason: `remove-unmounted = true`)", name(),
          string{TAG_LABEL_UNMOUNTED});
    }
  }
fs_module :: fs_module ( const bar_settings & bar , string name_ ) : timer_module < fs_module > ( bar , move ( name_ ) ) { m_mountpoints = m_conf . get_list ( name ( ) , " " ) ; m_remove_unmounted = m_conf . get ( name ( ) , " " , m_remove_unmounted ) ; m_perc_used_warn = m_conf . get ( name ( ) , " " , 90 ) ; m_fixed = m_conf . get ( name ( ) , " " , m_fixed ) ; m_spacing = m_conf . get ( name ( ) , " " , m_spacing ) ; set_interval ( 30 s ) ; m_formatter -> add ( FORMAT_MOUNTED , TAG_LABEL_MOUNTED , { TAG_LABEL_MOUNTED , TAG_BAR_FREE , TAG_BAR_USED , TAG_RAMP_CAPACITY } ) ; m_formatter -> add_optional ( FORMAT_WARN , { TAG_LABEL_WARN , TAG_BAR_FREE , TAG_BAR_USED , TAG_RAMP_CAPACITY } ) ; m_formatter -> add ( FORMAT_UNMOUNTED , TAG_LABEL_UNMOUNTED , { TAG_LABEL_UNMOUNTED } ) ; if ( m_formatter -> has ( TAG_LABEL_MOUNTED ) ) { m_labelmounted = load_optional_label ( m_conf , name ( ) , TAG_LABEL_MOUNTED , " " ) ; } if ( m_formatter -> has ( TAG_LABEL_WARN ) ) { m_labelwarn = load_optional_label ( m_conf , name ( ) , TAG_LABEL_WARN , " " ) ; } if ( m_formatter -> has ( TAG_LABEL_UNMOUNTED ) ) { m_labelunmounted = load_optional_label ( m_conf , name ( ) , TAG_LABEL_UNMOUNTED , " " ) ; } if ( m_formatter -> has ( TAG_BAR_FREE ) ) { m_barfree = load_progressbar ( m_bar , m_conf , name ( ) , TAG_BAR_FREE ) ; } if ( m_formatter -> has ( TAG_BAR_USED ) ) { m_barused = load_progressbar ( m_bar , m_conf , name ( ) , TAG_BAR_USED ) ; } if ( m_formatter -> has ( TAG_RAMP_CAPACITY ) ) { m_rampcapacity = load_ramp ( m_conf , name ( ) , TAG_RAMP_CAPACITY ) ; } if ( m_formatter -> has ( TAG_LABEL_UNMOUNTED ) && m_remove_unmounted ) { m_log . warn ( " \" \" " , name ( ) , string { TAG_LABEL_UNMOUNTED } ) ; } }
Bootstrap the module by reading config values and
 setting up required components
Bootstrap the module by reading config values and setting up required components
// Add formats and elements // Warn about "unreachable" format tag