mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-22 03:02:49 +00:00
Make the partition monitored by disk sensor configurable (#50)
Allows to stat partitions other than the root partition --------- Co-authored-by: Sebastian Zerbe <zerbe@phil.hhu.de>
This commit is contained in:
parent
9afbfe3c1d
commit
471bc6e719
7 changed files with 16 additions and 3 deletions
|
@ -22,6 +22,9 @@ ExitCommand: killall Hyprland
|
|||
# The folder, where the battery sensors reside
|
||||
BatteryFolder: /sys/class/power_supply/BAT1
|
||||
|
||||
# The partition to monitor with disk sensor
|
||||
DiskPartition: /
|
||||
|
||||
# Overrides the icon of the nth (in this case the first) workspace.
|
||||
# Please note the missing space between "," and the symbol. Adding a space here adds it to the bar too!
|
||||
#WorkspaceSymbol: 1,
|
||||
|
|
|
@ -58,6 +58,11 @@ in {
|
|||
default = "/sys/class/power_supply/BAT1";
|
||||
description = "The folder, where the battery sensors reside";
|
||||
};
|
||||
DiskPartition = mkOption {
|
||||
type = types.str;
|
||||
default = "/";
|
||||
description = "The partition to monitor with disk sensor";
|
||||
};
|
||||
WorkspaceSymbols = mkOption {
|
||||
type = types.nullOr (types.listOf types.str);
|
||||
default = [];
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace Bar
|
|||
{
|
||||
System::DiskInfo info = System::GetDiskInfo();
|
||||
|
||||
std::string text = "Disk: " + Utils::ToStringPrecision(info.usedGiB, "%0.2f") + "GiB/" +
|
||||
std::string text = "Disk " + info.partition + ": " + Utils::ToStringPrecision(info.usedGiB, "%0.2f") + "GiB/" +
|
||||
Utils::ToStringPrecision(info.totalGiB, "%0.2f") + "GiB";
|
||||
if (Config::Get().sensorTooltips)
|
||||
{
|
||||
|
|
|
@ -201,6 +201,7 @@ void Config::Load()
|
|||
AddConfigVar("DateTimeStyle", config.dateTimeStyle, lineView, foundProperty);
|
||||
AddConfigVar("DateTimeLocale", config.dateTimeLocale, lineView, foundProperty);
|
||||
AddConfigVar("CheckPackagesCommand", config.checkPackagesCommand, lineView, foundProperty);
|
||||
AddConfigVar("DiskPartition", config.diskPartition, lineView, foundProperty);
|
||||
|
||||
AddConfigVar("CenterTime", config.centerTime, lineView, foundProperty);
|
||||
AddConfigVar("AudioInput", config.audioInput, lineView, foundProperty);
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
std::string defaultWorkspaceSymbol = "";
|
||||
std::string dateTimeStyle = "%a %D - %H:%M:%S %Z"; // A sane default
|
||||
std::string dateTimeLocale = ""; // use system locale
|
||||
std::string diskPartition = "/"; // should be expectable on every linux system
|
||||
|
||||
// Script that returns how many packages are out-of-date. The script should only print a number!
|
||||
// See data/update.sh for a human-readable version
|
||||
|
|
|
@ -202,10 +202,12 @@ namespace System
|
|||
DiskInfo GetDiskInfo()
|
||||
{
|
||||
struct statvfs stat;
|
||||
int err = statvfs("/", &stat);
|
||||
ASSERT(err == 0, "Cannot stat root!");
|
||||
std::string partition = Config::Get().diskPartition;
|
||||
int err = statvfs(partition.c_str(), &stat);
|
||||
ASSERT(err == 0, "Cannot stat " + partition + "!");
|
||||
|
||||
DiskInfo out{};
|
||||
out.partition = partition;
|
||||
out.totalGiB = (double)(stat.f_blocks * stat.f_frsize) / (1024 * 1024 * 1024);
|
||||
out.usedGiB = (double)((stat.f_blocks - stat.f_bfree) * stat.f_frsize) / (1024 * 1024 * 1024);
|
||||
return out;
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace System
|
|||
|
||||
struct DiskInfo
|
||||
{
|
||||
std::string partition;
|
||||
double totalGiB;
|
||||
double usedGiB;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue