Skip to content

Commit

Permalink
query: add KiB variants for RAM and Disk
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni500github committed Aug 26, 2024
1 parent 1918594 commit f4649cb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ theme-gtk-all
font : gtk font theme name [Cantarell 10 [GTK2], Noto Sans, 10 [GTK3], Noto Sans 10 [GTK4]]
cursor : gtk cursor theme name [Bibata-Modern-Ice [GTK2], Qogir-dark [GTK3], Qogir [GTK4]]
# note: these members are auto displayed in kiB, MiB, GiB and TiB.
# they all (except ram.ram and ram.swap) have a -GiB and -MiB variant
# note: these members are auto displayed in KiB, MiB, GiB and TiB.
# they all (except ram.ram and ram.swap) have a -KiB, -GiB and -MiB variant
# example: if you want to show your 512MiB of used RAM in GiB
# use the used-GiB variant (they don't print the unit tho)
ram
Expand Down
17 changes: 13 additions & 4 deletions src/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,14 +782,16 @@ void addValueFromModule(systemInfo_t& sysInfo, const std::string& moduleName, co

switch (moduleValue_hash)
{
// clang-format off
case "fs"_fnv1a16: SYSINFO_INSERT(query_disk.typefs()); break;

// clang-format off
case "disk"_fnv1a16:
SYSINFO_INSERT(fmt::format("{:.2f} {} / {:.2f} {} - {}",
byte_units.at(USED).num_bytes, byte_units.at(USED).unit,
byte_units.at(TOTAL).num_bytes,byte_units.at(TOTAL).unit,
query_disk.typefs()));
break;
// clang-format on
// clang-format on

case "used"_fnv1a16:
SYSINFO_INSERT(fmt::format("{:.2f} {}", byte_units.at(USED).num_bytes, byte_units.at(USED).unit));
Expand All @@ -805,14 +807,15 @@ void addValueFromModule(systemInfo_t& sysInfo, const std::string& moduleName, co

case "used-GiB"_fnv1a16: SYSINFO_INSERT(query_disk.used_amount() / 1073741824); break;
case "used-MiB"_fnv1a16: SYSINFO_INSERT(query_disk.used_amount() / 1048576); break;
case "used-KiB"_fnv1a16: SYSINFO_INSERT(query_disk.used_amount() / 1024); break;

case "total-GiB"_fnv1a16: SYSINFO_INSERT(query_disk.total_amount() / 1073741824); break;
case "total-MiB"_fnv1a16: SYSINFO_INSERT(query_disk.total_amount() / 1048576); break;
case "total-KiB"_fnv1a16: SYSINFO_INSERT(query_disk.total_amount() / 1024); break;

case "free-GiB"_fnv1a16: SYSINFO_INSERT(query_disk.free_amount() / 1073741824); break;
case "free-MiB"_fnv1a16: SYSINFO_INSERT(query_disk.free_amount() / 1048576); break;

case "fs"_fnv1a16: SYSINFO_INSERT(query_disk.typefs()); break;
case "free-KiB"_fnv1a16: SYSINFO_INSERT(query_disk.free_amount() / 1024); break;
}
}
}
Expand Down Expand Up @@ -890,21 +893,27 @@ void addValueFromModule(systemInfo_t& sysInfo, const std::string& moduleName, co

case "used-GiB"_fnv1a16: SYSINFO_INSERT(query_ram.used_amount() / 1048576); break;
case "used-MiB"_fnv1a16: SYSINFO_INSERT(query_ram.used_amount() / 1024); break;
case "used-KiB"_fnv1a16: SYSINFO_INSERT(query_ram.used_amount()); break;

case "total-GiB"_fnv1a16: SYSINFO_INSERT(query_ram.total_amount() / 1048576); break;
case "total-MiB"_fnv1a16: SYSINFO_INSERT(query_ram.total_amount() / 1024); break;
case "total-KiB"_fnv1a16: SYSINFO_INSERT(query_ram.total_amount()); break;

case "free-GiB"_fnv1a16: SYSINFO_INSERT(query_ram.free_amount() / 1048576); break;
case "free-MiB"_fnv1a16: SYSINFO_INSERT(query_ram.free_amount() / 1024); break;
case "free-KiB"_fnv1a16: SYSINFO_INSERT(query_ram.free_amount()); break;

case "swap_free-GiB"_fnv1a16: SYSINFO_INSERT(query_ram.swap_free_amount() / 1048576); break;
case "swap_free-MiB"_fnv1a16: SYSINFO_INSERT(query_ram.swap_free_amount() / 1024); break;
case "swap_free-KiB"_fnv1a16: SYSINFO_INSERT(query_ram.swap_free_amount()); break;

case "swap_used-GiB"_fnv1a16: SYSINFO_INSERT(query_ram.swap_used_amount() / 1048576); break;
case "swap_used-MiB"_fnv1a16: SYSINFO_INSERT(query_ram.swap_used_amount() / 1024); break;
case "swap_used-KiB"_fnv1a16: SYSINFO_INSERT(query_ram.swap_used_amount()); break;

case "swap_total-GiB"_fnv1a16: SYSINFO_INSERT(query_ram.swap_total_amount() / 1048576); break;
case "swap_total-MiB"_fnv1a16: SYSINFO_INSERT(query_ram.swap_total_amount() / 1024); break;
case "swap_total-KiB"_fnv1a16: SYSINFO_INSERT(query_ram.swap_total_amount()); break;
}
}
}
Expand Down

0 comments on commit f4649cb

Please sign in to comment.