diff --git a/data/config b/data/config index 762e96c..acc3c9c 100644 --- a/data/config +++ b/data/config @@ -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, diff --git a/module.nix b/module.nix index beda1fb..9526d59 100644 --- a/module.nix +++ b/module.nix @@ -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 = []; diff --git a/src/Bar.cpp b/src/Bar.cpp index 208631a..4a08004 100644 --- a/src/Bar.cpp +++ b/src/Bar.cpp @@ -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) { diff --git a/src/Config.cpp b/src/Config.cpp index 7e0004d..275ec53 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -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); diff --git a/src/Config.h b/src/Config.h index 3800e32..5087e88 100644 --- a/src/Config.h +++ b/src/Config.h @@ -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 diff --git a/src/System.cpp b/src/System.cpp index ba121ec..35b69c2 100644 --- a/src/System.cpp +++ b/src/System.cpp @@ -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; diff --git a/src/System.h b/src/System.h index c0c45c3..73cc915 100644 --- a/src/System.h +++ b/src/System.h @@ -38,6 +38,7 @@ namespace System struct DiskInfo { + std::string partition; double totalGiB; double usedGiB; };