From 9a99fe300e6147fd0085e6a51f4188489fef818a Mon Sep 17 00:00:00 2001 From: Von Random Date: Fri, 7 Oct 2016 16:19:55 +0300 Subject: [PATCH] fix rounding for memory status --- i3_status | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/i3_status b/i3_status index 52353d8..5c35bda 100755 --- a/i3_status +++ b/i3_status @@ -17,9 +17,11 @@ while True: current_time = time.strftime('%a %d %H:%M') values.append(current_time) mem = psutil.virtual_memory() - memory = 'RAM: {}% ({:.3}G)'.format(100.0 - mem.percent, mem.available / 2**30) + memory = 'RAM: {}% ({}G)'.format(round(100.0 - mem.percent, 2), + round(mem.available / 2**30, 2)) values.append(memory) - with open('/sys/class/power_supply/BAT0/capacity', 'r') as capacity, open('/sys/class/power_supply/BAT0/status', 'r') as status: + with open('/sys/class/power_supply/BAT0/capacity', 'r') as capacity, \ + open('/sys/class/power_supply/BAT0/status', 'r') as status: batt_status = status.read().strip() batt_capacity = capacity.read().strip() if batt_status != 'Discharging':