2

I'm trying to get a small script running to display information about CPU and GPU usage. The script is complete and outputs information in the following format

 CPU 2% 37C GPU 0% 56C 

I'm also displaying it via xosd using the second script:

#!/bin/sh file=$(mktemp --suffix=osdtmp) tail -f $file | osd_cat -o 30 -i 5 -d 1 -l 2 - & while true; do ./temps.sh >> $file done rm -f $file 

The script reads any changes from the file and refreshes the two lines displayed on screen. My problem is that whenever the data is refreshed there is a noticeable flicker, which is quite annoying.

I don't have to use xosd, but this seemed to be the best tool for the job.

How can I display a small text overlay and refresh it periodically without it flickering?

1 Answer 1

1

I know it's an old post, but I found it was the only one when searching online.

What you can do is print the elements that don't change first, like CPU % C

Then with another process of osd_cat you print the values that do change.

I found using the popular example of piping the output of a loop that has a sleep to osd_cat causes them to go out of sync and even more flicker.

Here's how I did it for example: https://github.com/kevinlekiller/shell_scripts/blob/main/misc/osd_stats.sh

Edit: With the solution I provided, there's no flicker, but there's a transition between when osd_cat prints on the screen, this is because the osd_cat process terminates, then the string has to be computed and osd_cat is called again, the transition we see, is that in between time.

We can get rid of this transition time by forking the call to osd_cat in the loop, then we use sleep inside the loop, with a slightly lower delay than the time we for osd_cat, this might cause a bit of a overlap for a few milliseconds, but we don't see the transition. I'll edit the script I linked above and add these changes.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.