Fixed CPU usage and memory for i3blocks

This commit is contained in:
2018-12-03 14:01:54 -05:00
parent 6e90123d6f
commit ad5772fae9
5 changed files with 19 additions and 21 deletions

View File

@@ -29,7 +29,7 @@ GetOptions("help|h" => \&help,
# Get CPU usage
$ENV{LC_ALL}="en_US"; # if mpstat is not run under en_US locale, things may break, so make sure it is
open (MPSTAT, 'mpstat 1 1 |') or die;
open (MPSTAT, 'mpstat |') or die;
while (<MPSTAT>) {
if (/^.*\s+(\d+\.\d+)\s+$/) {
$cpu_usage = 100 - $1; # 100% - %idle

View File

@@ -40,7 +40,7 @@ END {
if (type == "swap")
printf("%.1fG\n", (swap_total-swap_free)/1024/1024)
else
printf("%.1fG\n", mem_free/1024/1024)
printf("%.1fG\n", (mem_total-mem_free)/1024/1024)
# TODO: short text