feat(fs): New filesystem module
Module that displays details about mounted filesystems, #84 Closes #153
This commit is contained in:
parent
ed5b7a508a
commit
9a0df75a91
9 changed files with 343 additions and 3 deletions
include/modules
77
include/modules/fs.hpp
Normal file
77
include/modules/fs.hpp
Normal file
|
@ -0,0 +1,77 @@
|
|||
#pragma once
|
||||
|
||||
#include "components/config.hpp"
|
||||
#include "config.hpp"
|
||||
#include "drawtypes/label.hpp"
|
||||
#include "drawtypes/progressbar.hpp"
|
||||
#include "drawtypes/ramp.hpp"
|
||||
#include "modules/meta.hpp"
|
||||
|
||||
LEMONBUDDY_NS
|
||||
|
||||
namespace modules {
|
||||
/**
|
||||
* Filesystem structure
|
||||
*/
|
||||
struct fs_disk {
|
||||
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;
|
||||
|
||||
explicit fs_disk(const string& mountpoint, bool mounted = false)
|
||||
: mountpoint(mountpoint), mounted(mounted) {}
|
||||
};
|
||||
|
||||
using fs_disk_t = unique_ptr<fs_disk>;
|
||||
|
||||
/**
|
||||
* Module used to display filesystem stats.
|
||||
*/
|
||||
class fs_module : public timer_module<fs_module> {
|
||||
public:
|
||||
using timer_module::timer_module;
|
||||
|
||||
void setup();
|
||||
bool update();
|
||||
string get_format() const;
|
||||
string get_output();
|
||||
bool build(builder* builder, string tag) const;
|
||||
|
||||
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;
|
||||
|
||||
vector<string> m_mounts;
|
||||
vector<fs_disk_t> m_disks;
|
||||
bool m_fixed = false;
|
||||
int m_spacing = 2;
|
||||
|
||||
// used while formatting output
|
||||
size_t m_index = 0;
|
||||
};
|
||||
}
|
||||
|
||||
LEMONBUDDY_NS_END
|
Loading…
Add table
Add a link
Reference in a new issue