Fixed: Get real / mountpoint when running inside snap

This commit is contained in:
aristocratos 2021-09-28 21:01:50 +02:00
parent ff6d1d6eec
commit 06cac6756d
2 changed files with 10 additions and 0 deletions

View File

@ -34,6 +34,7 @@ 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

View File

@ -679,6 +679,7 @@ namespace Mem {
auto& swap_disk = Config::getB("swap_disk"); auto& swap_disk = Config::getB("swap_disk");
auto& show_disks = Config::getB("show_disks"); auto& show_disks = Config::getB("show_disks");
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;
@ -803,6 +804,14 @@ namespace Mem {
std::error_code ec; std::error_code ec;
diskread >> dev >> mountpoint >> fstype; diskread >> dev >> mountpoint >> fstype;
//? If running snapped, remove internal / mountpoint and replace /mnt with / to get correct device
if (snapped) {
if (mountpoint == "/")
continue;
else if (mountpoint == "/mnt")
mountpoint = "/";
}
//? Match filter if not empty //? Match filter if not empty
if (not filter.empty()) { if (not filter.empty()) {
bool match = v_contains(filter, mountpoint); bool match = v_contains(filter, mountpoint);