diff --git a/evga-icx.c b/evga-icx.c index 3fd3084..3dc8d7f 100644 --- a/evga-icx.c +++ b/evga-icx.c @@ -204,8 +204,10 @@ int main (int argc, char **argv) /* print sensor info */ if (print_info) { do { - if (overwrite) + if (overwrite) { + printf("\x1b[?25l"); /* Hide cursor */ printf("\x1b[K"); /* Clear current console line */ + } if (print_board_sensors) print_board_info(board_sensors, board_sensor_count); @@ -224,14 +226,17 @@ int main (int argc, char **argv) if (!overwrite) printf("\n"); /* Print line break at the end for continuous output */ - if (overwrite && compact) { - printf("\x1b[1G"); /* Move cursor back to column 1 */ - if (gpu_count > 1 || print_board_sensors) - printf("\x1b[%dA", gpu_count-1+print_board_sensors); /* Move cursor back up to the top of gpu list */ - } - fflush(stdout); sleep(watch); + + if (overwrite && compact) { + printf("\x1b[1G"); /* Move cursor back to column 1 */ + for (int i = 0; i < gpu_count+print_board_sensors; i++) { + printf("\x1b[K"); /* Clear current console line */ + printf("\x1b[1A"); /* Move cursor up one line */ + } + } + } while (watch > 0); }