Calculating values for the Xfce Sensors Plugin

I extensively use the Xfce panel to monitor my system. I like having a picture of its state without having to launch any diagnostic tool. This proves to be quite useful! Also, should my computer experience a sudden problem and not respond anymore, I can glance at its last state before rebooting.

I have never liked the excess of colors that is present on the bar, though:

The top panel on my Xfce session showing multiple sensors and how it shows too many distracting colors.

The top panel on my Xfce session showing multiple sensors and how it shows too many distracting colors. Taken from My laptop was broken into.

This takes away from noticing effortlessly whenever something out of the ordinary is occurring. So I put everything (or as much as possible) in gray shades. I managed to change its appearance quite easily:

  • For the Applications menu I chose an already-available gray-scale icon.
  • I removed unneeded icons, favoring a shortcut in Superkb.
  • For the weather applet I used the Liquid Dark icon theme.
  • I also changed the notification area by switching my whole Xfce appearance to the Adwaita-Dark style with Moka icons.
  • I changed the system monitors colors so it’s all gray if everything is normal:
    • CPU chart colors (the bars are hardcoded blue, but this is okay since I want to somewhat notice any CPU usage).
    • The RAM monitor uses fixed colors so I put physical RAM in gray. I put swap on bright yellow, as it’s bad to be using too much swap and I want to notice it.
    • Both NIC monitors follow a similar approach: gray for download, yellow for upload.
    • The disk monitor also uses the gray/yellow approach: gray for reading, yellow for writing.
    • For the weather plugin I used Kevin Hanselman’s WSky-Light theme.

The Sensors Plugin needed some fine-tuning, though…

Fine-tuning the Sensors Plugin

The Sensors Plugin has many display modes. The most unobtrusive is the bar mode. Also, you can set lower and upper limits for each sensor. With its Show colored bars mode, a bar will change from the set color to yellow if its value is within 20% of a limit and to red if it’s within 10% of a limit. So, if I measure a sensor and I configure it to plot between 0 and 10, the bar will turn yellow when the sensor measures 1.5 or 8.5 and red for measurements like 0.5 or 9.5.

I want the colors to turn yellow or red only if I want to notice something; otherwise just plain, boring, unnoticeable gray. I want the bars not stand out if everything is within normal values. That implies making some calculations to figure out the actual minimum and maximum values for the sensor on configuration so nominal values always stay between 20% and 80% area.

This suits most cases. However, in the case of CPU temperature, though, I am rather interested on fixing the red value, so instead of calculating between 20% and 80% I wanted to calculate between 20% and 90%; it does not matter if the CPU sensor turns yellow.

Calculating the plotting range: the minimum and maximum values

For the calculations, there are four inputs given:

  • P_high: The percentage within the plotting range I want to use for fixing the too high value.
  • V_high: The value to be fixed to the P_high percentage point of the plotting range.
  • P_low: The percentage within the plotting range I want to use for fixing the too low value.
  • V_low: The value to be fixed to the P_low percentage point of the plotting range.

I am calling the plotting range the absolute minimum and maximum values on a bar. If a value goes below the minimum, the bar will be empty. If it goes beyond the maximum, the bar will be full.

Notice that minimum and low are not the same thing: minimum is the lowest possible value in the plotting range (as explained just above) while low is the value I am interested in fixing to a specific color on the lower side.

First, a intermediate range value must be calculated:

range = ( V_high - V_low ) / ( P_high - P_low )

Once having the Range calculated the minimum and maximum can be determined by:

min = V_low - (P_low)*(range)

max = V_high + (1 - P_high )*(range)

Example

For the CPU temperature I want this behavior:

Start gray at 39 C, the lowest temperature I measured when idle ever. It should turn yellow below this value. This is the 20% point in the chart.

Turn red if it goes above than 81 C, the highest temperature I measured under the heaviest load possible with the new thermal paste. 81 C is quite high already, being 89 C the shutdown limit. This is why I want it directly red by then and I don’t care if it’s yellow a bit before. So, this will be the 90% point in the chart.

range = ( 81 - 39 ) / ( 0.9 - 0.2 ) = 60

min = 39 - ( 0.2 )*( 60 ) = 27

max = 81 + ( 1 - 0.9 )*( 60 ) = 87

So I configured that bar on the Sensors Plugin to plot from 27 to 87 C. This way, the sensor will turn red above 81 C and yellow only below 39 C.

Final result

Since I started writing this post to the moment I finished it, some additional unrelated changes occurred:

  1. I switched from Hexchat to Quassel. This was done because I installed Quassel core so I could have a better IRC experience.
  2. I installed the kbdleds plugin. It’s old and obsolete, but it works. I have an on-screen indicator of NumLock, as my laptop keyboard does not provide one.

This is how the final bar looks like:

final

It will probably be too wide for most displays, so here it is again, split in three sections:

Bar, left section: applications menu with gray icon, terminal launcher in black, and CPU, RAM, NICs and disk monitors; the only color shown is blue, by the CPU monitor.

Left section of the bar.

Bar, center section: two weather widgets and the date and time with seconds and timezone, all in the same color.

Center section of the bar.

Bar, right section: keyboard pseudo-LED indicators, notification area, temperature sensors and user menu, all in the same color except for the keyboard pseudo-LEDs.

Right section of the bar.

I like it! It’s much less distracting, much less cartoony!

Update: BTW, if you want to make your own calculations quickly, download and use this LibreOffice Calc spreadsheet: sensors.ods


Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *