diff --git a/src/common.c b/src/common.c index f1bffcb4..4e140db6 100644 --- a/src/common.c +++ b/src/common.c @@ -525,11 +525,11 @@ uint8_t swap_percentage(struct text_object *obj) return (info.swapmax ? round_to_int(info.swap * 100 / info.swapmax) : 0); } -uint8_t swap_barval(struct text_object *obj) +double swap_barval(struct text_object *obj) { (void)obj; - return round_to_int(info.swapmax ? (info.swap * 255 / info.swapmax) : 0); + return info.swapmax ? ((double)info.swap / info.swapmax) : 0; } void print_kernel(struct text_object *obj, char *p, int p_max_size) diff --git a/src/common.h b/src/common.h index cef49295..5fae3d23 100644 --- a/src/common.h +++ b/src/common.h @@ -83,7 +83,7 @@ void print_swapmax(struct text_object *, char *, int); uint8_t mem_percentage(struct text_object *); double mem_barval(struct text_object *); uint8_t swap_percentage(struct text_object *); -uint8_t swap_barval(struct text_object *); +double swap_barval(struct text_object *); void print_kernel(struct text_object *, char *, int); void print_machine(struct text_object *, char *, int); diff --git a/src/core.c b/src/core.c index a6f5749b..8b0d7300 100644 --- a/src/core.c +++ b/src/core.c @@ -1032,7 +1032,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long END OBJ(swapperc, &update_meminfo) obj->callbacks.percentage = &swap_percentage; END OBJ(swapbar, &update_meminfo) - scan_bar(obj, arg, 255); + scan_bar(obj, arg, 1); obj->callbacks.barval = &swap_barval; /* XXX: swapgraph, swapgauge? */ END OBJ(sysname, 0)