mirror of
https://github.com/aristocratos/btop.git
synced 2024-09-29 16:51:40 +13:00
Fixed: snap root disk and changed to compiler flags instead of env variables for detection
This commit is contained in:
parent
ad0b3d6b09
commit
dbcd12b9d0
2 changed files with 16 additions and 8 deletions
|
@ -29,7 +29,6 @@ apps:
|
||||||
environment:
|
environment:
|
||||||
LC_ALL: C.UTF-8
|
LC_ALL: C.UTF-8
|
||||||
LANG: C.UTF-8
|
LANG: C.UTF-8
|
||||||
BTOP_SNAPPED: true
|
|
||||||
plugs:
|
plugs:
|
||||||
- mount-observe
|
- mount-observe
|
||||||
- process-control
|
- process-control
|
||||||
|
@ -48,7 +47,7 @@ parts:
|
||||||
make-parameters:
|
make-parameters:
|
||||||
- PREFIX=/usr/local
|
- PREFIX=/usr/local
|
||||||
- STATIC=true
|
- STATIC=true
|
||||||
- BTOP_SNAPPED=1
|
- ADDFLAGS="-D SNAPPED"
|
||||||
|
|
||||||
build-packages:
|
build-packages:
|
||||||
- coreutils
|
- coreutils
|
||||||
|
|
|
@ -686,7 +686,6 @@ namespace Mem {
|
||||||
auto& show_disks = Config::getB("show_disks");
|
auto& show_disks = Config::getB("show_disks");
|
||||||
auto totalMem = get_totalMem();
|
auto totalMem = get_totalMem();
|
||||||
auto& mem = current_mem;
|
auto& mem = current_mem;
|
||||||
static const bool snapped = (getenv("BTOP_SNAPPED") != NULL);
|
|
||||||
|
|
||||||
mem.stats.at("swap_total") = 0;
|
mem.stats.at("swap_total") = 0;
|
||||||
|
|
||||||
|
@ -791,8 +790,12 @@ namespace Mem {
|
||||||
for (string instr; diskread >> instr;) {
|
for (string instr; diskread >> instr;) {
|
||||||
if (not instr.starts_with('#')) {
|
if (not instr.starts_with('#')) {
|
||||||
diskread >> instr;
|
diskread >> instr;
|
||||||
if (snapped and instr == "/") fstab.push_back("/mnt");
|
#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);
|
||||||
|
#else
|
||||||
|
if (not is_in(instr, "none", "swap")) fstab.push_back(instr);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
diskread.ignore(SSmax, '\n');
|
diskread.ignore(SSmax, '\n');
|
||||||
}
|
}
|
||||||
|
@ -829,7 +832,10 @@ namespace Mem {
|
||||||
if (not disks.contains(mountpoint)) {
|
if (not disks.contains(mountpoint)) {
|
||||||
disks[mountpoint] = disk_info{fs::canonical(dev, ec), fs::path(mountpoint).filename()};
|
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).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();
|
string devname = disks.at(mountpoint).dev.filename();
|
||||||
while (devname.size() >= 2) {
|
while (devname.size() >= 2) {
|
||||||
if (fs::exists("/sys/block/" + devname + "/stat", ec) and access(string("/sys/block/" + devname + "/stat").c_str(), R_OK) == 0) {
|
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
|
//? Setup disks order in UI and add swap if enabled
|
||||||
mem.disks_order.clear();
|
mem.disks_order.clear();
|
||||||
if (snapped and disks.contains("/mnt")) mem.disks_order.push_back("/mnt");
|
#ifdef SNAPPED
|
||||||
else if (disks.contains("/")) mem.disks_order.push_back("/");
|
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) {
|
if (swap_disk and has_swap) {
|
||||||
mem.disks_order.push_back("swap");
|
mem.disks_order.push_back("swap");
|
||||||
if (not disks.contains("swap")) disks["swap"] = {"", "swap"};
|
if (not disks.contains("swap")) disks["swap"] = {"", "swap"};
|
||||||
|
|
Loading…
Reference in a new issue