2016-11-13 00:09:51 -05:00
|
|
|
#pragma once
|
|
|
|
|
2021-02-15 17:32:56 -05:00
|
|
|
#include <utility>
|
|
|
|
|
2016-11-13 00:09:51 -05:00
|
|
|
#include "components/config.hpp"
|
2016-11-20 17:04:31 -05:00
|
|
|
#include "modules/meta/timer_module.hpp"
|
2020-05-15 13:59:08 -04:00
|
|
|
#include "settings.hpp"
|
2016-11-13 00:09:51 -05:00
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS
|
2016-11-13 00:09:51 -05:00
|
|
|
|
|
|
|
namespace modules {
|
|
|
|
/**
|
|
|
|
* Filesystem structure
|
|
|
|
*/
|
2016-11-13 02:50:00 -05:00
|
|
|
struct fs_mount {
|
2016-11-13 00:09:51 -05:00
|
|
|
string mountpoint;
|
|
|
|
bool mounted = false;
|
|
|
|
|
|
|
|
string type;
|
|
|
|
string fsname;
|
|
|
|
|
2019-01-16 18:05:36 -05:00
|
|
|
uint64_t bytes_free{0ULL};
|
|
|
|
uint64_t bytes_used{0ULL};
|
|
|
|
uint64_t bytes_avail{0ULL};
|
|
|
|
uint64_t bytes_total{0ULL};
|
2016-11-13 00:09:51 -05:00
|
|
|
|
2017-01-12 14:28:44 -05:00
|
|
|
int percentage_free{0};
|
|
|
|
int percentage_used{0};
|
2016-11-13 00:09:51 -05:00
|
|
|
|
2021-02-15 17:32:56 -05:00
|
|
|
explicit fs_mount(string mountpoint, bool mounted = false) : mountpoint(move(mountpoint)), mounted(mounted) {}
|
2016-11-13 00:09:51 -05:00
|
|
|
};
|
|
|
|
|
2016-11-13 02:50:00 -05:00
|
|
|
using fs_mount_t = unique_ptr<fs_mount>;
|
2016-11-13 00:09:51 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Module used to display filesystem stats.
|
|
|
|
*/
|
|
|
|
class fs_module : public timer_module<fs_module> {
|
|
|
|
public:
|
2016-12-21 02:00:09 -05:00
|
|
|
explicit fs_module(const bar_settings&, string);
|
2016-11-13 00:09:51 -05:00
|
|
|
|
|
|
|
bool update();
|
|
|
|
string get_format() const;
|
|
|
|
string get_output();
|
2016-11-25 07:55:15 -05:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-11-13 00:09:51 -05:00
|
|
|
|
2020-05-15 13:59:08 -04:00
|
|
|
static constexpr auto TYPE = "internal/fs";
|
|
|
|
|
2016-11-13 00:09:51 -05:00
|
|
|
private:
|
|
|
|
static constexpr auto FORMAT_MOUNTED = "format-mounted";
|
2020-12-02 09:55:13 -05:00
|
|
|
static constexpr auto FORMAT_WARN = "format-warn";
|
2016-11-13 00:09:51 -05:00
|
|
|
static constexpr auto FORMAT_UNMOUNTED = "format-unmounted";
|
|
|
|
static constexpr auto TAG_LABEL_MOUNTED = "<label-mounted>";
|
|
|
|
static constexpr auto TAG_LABEL_UNMOUNTED = "<label-unmounted>";
|
2020-12-02 09:55:13 -05:00
|
|
|
static constexpr auto TAG_LABEL_WARN = "<label-warn>";
|
2016-11-13 00:09:51 -05:00
|
|
|
static constexpr auto TAG_BAR_USED = "<bar-used>";
|
|
|
|
static constexpr auto TAG_BAR_FREE = "<bar-free>";
|
|
|
|
static constexpr auto TAG_RAMP_CAPACITY = "<ramp-capacity>";
|
|
|
|
|
|
|
|
label_t m_labelmounted;
|
|
|
|
label_t m_labelunmounted;
|
2020-12-02 09:55:13 -05:00
|
|
|
label_t m_labelwarn;
|
2016-11-13 00:09:51 -05:00
|
|
|
progressbar_t m_barused;
|
|
|
|
progressbar_t m_barfree;
|
|
|
|
ramp_t m_rampcapacity;
|
|
|
|
|
2016-11-13 02:50:00 -05:00
|
|
|
vector<string> m_mountpoints;
|
|
|
|
vector<fs_mount_t> m_mounts;
|
2016-12-30 16:44:28 -05:00
|
|
|
bool m_fixed{false};
|
|
|
|
bool m_remove_unmounted{false};
|
|
|
|
int m_spacing{2};
|
2020-12-02 09:55:13 -05:00
|
|
|
int m_perc_used_warn{90};
|
2016-11-13 00:09:51 -05:00
|
|
|
|
|
|
|
// used while formatting output
|
2016-12-30 16:44:28 -05:00
|
|
|
size_t m_index{0_z};
|
2016-11-13 00:09:51 -05:00
|
|
|
};
|
2020-05-15 13:59:08 -04:00
|
|
|
} // namespace modules
|
2016-11-13 00:09:51 -05:00
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS_END
|