2016-11-13 05:09:51 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "components/config.hpp"
|
|
|
|
#include "config.hpp"
|
2016-11-20 22:04:31 +00:00
|
|
|
#include "modules/meta/timer_module.hpp"
|
2016-11-13 05:09:51 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS
|
2016-11-13 05:09:51 +00:00
|
|
|
|
|
|
|
namespace modules {
|
|
|
|
/**
|
|
|
|
* Filesystem structure
|
|
|
|
*/
|
2016-11-13 07:50:00 +00:00
|
|
|
struct fs_mount {
|
2016-11-13 05:09:51 +00:00
|
|
|
string mountpoint;
|
|
|
|
bool mounted = false;
|
|
|
|
|
|
|
|
string type;
|
|
|
|
string fsname;
|
|
|
|
|
|
|
|
unsigned long long bytes_free = 0;
|
|
|
|
unsigned long long bytes_used = 0;
|
|
|
|
unsigned long long bytes_total = 0;
|
|
|
|
|
|
|
|
float percentage_free = 0;
|
|
|
|
float percentage_used = 0;
|
|
|
|
|
|
|
|
string percentage_free_s;
|
|
|
|
string percentage_used_s;
|
|
|
|
|
2016-11-25 07:42:31 +00:00
|
|
|
explicit fs_mount(const string& mountpoint, bool mounted = false) : mountpoint(mountpoint), mounted(mounted) {}
|
2016-11-13 05:09:51 +00:00
|
|
|
};
|
|
|
|
|
2016-11-13 07:50:00 +00:00
|
|
|
using fs_mount_t = unique_ptr<fs_mount>;
|
2016-11-13 05:09:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Module used to display filesystem stats.
|
|
|
|
*/
|
|
|
|
class fs_module : public timer_module<fs_module> {
|
|
|
|
public:
|
2016-12-21 07:00:09 +00:00
|
|
|
explicit fs_module(const bar_settings&, string);
|
2016-11-13 05:09:51 +00:00
|
|
|
|
|
|
|
bool update();
|
|
|
|
string get_format() const;
|
|
|
|
string get_output();
|
2016-11-25 12:55:15 +00:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-11-13 05:09:51 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static constexpr auto FORMAT_MOUNTED = "format-mounted";
|
|
|
|
static constexpr auto FORMAT_UNMOUNTED = "format-unmounted";
|
|
|
|
static constexpr auto TAG_LABEL_MOUNTED = "<label-mounted>";
|
|
|
|
static constexpr auto TAG_LABEL_UNMOUNTED = "<label-unmounted>";
|
|
|
|
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;
|
|
|
|
progressbar_t m_barused;
|
|
|
|
progressbar_t m_barfree;
|
|
|
|
ramp_t m_rampcapacity;
|
|
|
|
|
2016-11-13 07:50:00 +00:00
|
|
|
vector<string> m_mountpoints;
|
|
|
|
vector<fs_mount_t> m_mounts;
|
2016-12-30 21:44:28 +00:00
|
|
|
bool m_fixed{false};
|
|
|
|
bool m_remove_unmounted{false};
|
|
|
|
int m_spacing{2};
|
2016-11-13 05:09:51 +00:00
|
|
|
|
|
|
|
// used while formatting output
|
2016-12-30 21:44:28 +00:00
|
|
|
size_t m_index{0_z};
|
2016-11-13 05:09:51 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS_END
|