Add a disk module

This commit is contained in:
Guillaume Maudoux
2019-09-23 22:25:54 +02:00
parent 4667afaa98
commit 1d39ef5c8e
8 changed files with 126 additions and 20 deletions

View File

@ -13,6 +13,7 @@
#include "modules/cpu.hpp"
#include "modules/idle_inhibitor.hpp"
#include "modules/memory.hpp"
#include "modules/disk.hpp"
#if defined(HAVE_DBUSMENU) && !defined(NO_FILESYSTEM)
#include "modules/sni/tray.hpp"
#endif

23
include/modules/disk.hpp Normal file
View File

@ -0,0 +1,23 @@
#pragma once
#include <fmt/format.h>
#include <fstream>
#include <sys/statvfs.h>
#include "ALabel.hpp"
#include "util/sleeper_thread.hpp"
#include "util/format.hpp"
namespace waybar::modules {
class Disk : public ALabel {
public:
Disk(const std::string&, const Json::Value&);
~Disk() = default;
auto update() -> void;
private:
util::SleeperThread thread_;
std::string path_;
};
} // namespace waybar::modules

9
include/util/format.hpp Normal file
View File

@ -0,0 +1,9 @@
#pragma once
#include <sstream>
namespace waybar::util {
std::string pow_format(unsigned long long value, const std::string &unit, bool binary = false);
}