diff options
author | aristocratos <gnmjpl@gmail.com> | 2021-10-06 11:25:10 +0200 |
---|---|---|
committer | aristocratos <gnmjpl@gmail.com> | 2021-10-06 11:25:10 +0200 |
commit | dbcd12b9d0d7c8c5ce95e066b40118a6faa78063 (patch) | |
tree | 0c5219e4c51a2a303d31d402047a8527e9cffee7 /src | |
parent | ad0b3d6b097aaca2c718dc2901748527f7ce60b3 (diff) |
Fixed: snap root disk and changed to compiler flags instead of env variables for detection
Diffstat (limited to 'src')
-rw-r--r-- | src/linux/btop_collect.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/linux/btop_collect.cpp b/src/linux/btop_collect.cpp index 376be7f..ff72654 100644 --- a/src/linux/btop_collect.cpp +++ b/src/linux/btop_collect.cpp @@ -686,7 +686,6 @@ namespace Mem { auto& show_disks = Config::getB("show_disks"); auto totalMem = get_totalMem(); auto& mem = current_mem; - static const bool snapped = (getenv("BTOP_SNAPPED") != NULL); mem.stats.at("swap_total") = 0; @@ -791,8 +790,12 @@ namespace Mem { for (string instr; diskread >> instr;) { if (not instr.starts_with('#')) { diskread >> instr; - if (snapped and instr == "/") fstab.push_back("/mnt"); - else if (not is_in(instr, "none", "swap")) fstab.push_back(instr); + #ifdef SNAPPED + if (instr == "/") fstab.push_back("/mnt"); + else if (not is_in(instr, "none", "swap")) fstab.push_back(instr); + #else + if (not is_in(instr, "none", "swap")) fstab.push_back(instr); + #endif } diskread.ignore(SSmax, '\n'); } @@ -829,7 +832,10 @@ namespace Mem { if (not disks.contains(mountpoint)) { disks[mountpoint] = disk_info{fs::canonical(dev, ec), fs::path(mountpoint).filename()}; if (disks.at(mountpoint).dev.empty()) disks.at(mountpoint).dev = dev; - if (disks.at(mountpoint).name.empty()) disks.at(mountpoint).name = (mountpoint == "/" or (snapped and mountpoint == "/mnt") ? "root" : mountpoint); + #ifdef SNAPPED + if (mountpoint == "/mnt") disks.at(mountpoint).name = "root"; + #endif + if (disks.at(mountpoint).name.empty()) disks.at(mountpoint).name = (mountpoint == "/" ? "root" : mountpoint); string devname = disks.at(mountpoint).dev.filename(); while (devname.size() >= 2) { if (fs::exists("/sys/block/" + devname + "/stat", ec) and access(string("/sys/block/" + devname + "/stat").c_str(), R_OK) == 0) { @@ -875,8 +881,11 @@ namespace Mem { //? Setup disks order in UI and add swap if enabled mem.disks_order.clear(); - if (snapped and disks.contains("/mnt")) mem.disks_order.push_back("/mnt"); - else if (disks.contains("/")) mem.disks_order.push_back("/"); + #ifdef SNAPPED + if (disks.contains("/mnt")) mem.disks_order.push_back("/mnt"); + #else + if (disks.contains("/")) mem.disks_order.push_back("/"); + #endif if (swap_disk and has_swap) { mem.disks_order.push_back("swap"); if (not disks.contains("swap")) disks["swap"] = {"", "swap"}; |