From baabbe78b2a355d375b7ab5dc181a12b60fcd76e Mon Sep 17 00:00:00 2001 From: aristocratos Date: Sun, 13 Feb 2022 00:33:20 +0100 Subject: [PATCH] Added: Toggle for showing free disk space for privileged or normal users --- src/btop_config.cpp | 3 +++ src/btop_menu.cpp | 11 +++++++++-- src/linux/btop_collect.cpp | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/btop_config.cpp b/src/btop_config.cpp index 1883dfa..c509a8a 100644 --- a/src/btop_config.cpp +++ b/src/btop_config.cpp @@ -151,6 +151,8 @@ namespace Config { {"use_fstab", "#* Read disks list from /etc/fstab. This also disables only_physical."}, + {"disk_free_priv", "#* Set to true to show available disk space for privileged users."}, + {"show_io_stat", "#* Toggles if io activity % (disk busy time) should be shown in regular disk usage view."}, {"io_mode", "#* Toggles io mode for disks, showing big graphs for disk read/write speeds."}, @@ -242,6 +244,7 @@ namespace Config { {"show_battery", true}, {"vim_keys", false}, {"tty_mode", false}, + {"disk_free_priv", false}, {"force_tty", false}, {"lowcolor", false}, {"show_detailed", false}, diff --git a/src/btop_menu.cpp b/src/btop_menu.cpp index 3e212df..3eeedd8 100644 --- a/src/btop_menu.cpp +++ b/src/btop_menu.cpp @@ -464,12 +464,19 @@ namespace Menu { "", "True or False."}, {"use_fstab", - "Read disks list from /etc/fstab.", - "(Has no effect on macOS X)", + "(Linux) Read disks list from /etc/fstab.", "", "This also disables only_physical.", "", "True or False."}, + {"disk_free_priv", + "(Linux) Type of available disk space.", + "", + "Set to true to show how much disk space is", + "available for privileged users.", + "", + "Set to false to show available for normal", + "users."}, {"disks_filter", "Optional filter for shown disks.", "", diff --git a/src/linux/btop_collect.cpp b/src/linux/btop_collect.cpp index 79a6eac..62ae505 100644 --- a/src/linux/btop_collect.cpp +++ b/src/linux/btop_collect.cpp @@ -817,6 +817,7 @@ namespace Mem { //? Get disks stats if (show_disks) { double uptime = system_uptime(); + auto free_priv = Config::getB("disk_free_priv"); try { auto& disks_filter = Config::getS("disks_filter"); bool filter_exclude = false; @@ -943,7 +944,7 @@ namespace Mem { continue; } disk.total = vfs.f_blocks * vfs.f_frsize; - disk.free = vfs.f_bfree * vfs.f_frsize; + disk.free = (free_priv ? vfs.f_bfree : vfs.f_bavail) * vfs.f_frsize; disk.used = disk.total - disk.free; disk.used_percent = round((double)disk.used * 100 / disk.total); disk.free_percent = 100 - disk.used_percent;