Created
April 26, 2025 10:07
-
-
Save tbonfort/5be1441c94d2672f018c7e4b93943c82 to your computer and use it in GitHub Desktop.
psensor fixed graph bounds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use fixed graph bounds | |
--- a/psensor.desktop | |
+++ b/psensor.desktop | |
@@ -7,7 +7,7 @@ | |
Keywords=temperature;fan;monitoring;indicator; | |
Icon=psensor | |
TryExec=psensor | |
-Exec=psensor | |
+Exec=env GDK_BACKEND=x11 psensor | |
Categories=System;Monitor; | |
X-GNOME-Autostart-Delay=30 | |
StartupNotify=true | |
--- a/src/graph.c | |
+++ b/src/graph.c | |
@@ -479,13 +479,13 @@ | |
{ | |
int et, bt, width, height, g_width, g_height; | |
double min_rpm, max_rpm, mint, maxt, min, max; | |
- char *strmin, *strmax; | |
+ char *strmin, *strmax, *str_rpm_max; | |
/* horizontal and vertical offset of the graph */ | |
int g_xoff, g_yoff, no_graphs, use_celsius; | |
cairo_surface_t *cst; | |
cairo_t *cr, *cr_pixmap; | |
char *str_btime, *str_etime; | |
- cairo_text_extents_t te_btime, te_etime, te_max, te_min; | |
+ cairo_text_extents_t te_btime, te_etime, te_max, te_min, te_rpm_max; | |
struct psensor **sensor_cur, **enabled_sensors; | |
GtkAllocation galloc; | |
struct graph_info info; | |
@@ -500,6 +500,10 @@ | |
min_rpm = get_min_rpm(enabled_sensors); | |
max_rpm = get_max_rpm(enabled_sensors); | |
+ min_rpm=0; | |
+ if (max_rpm < 3000) max_rpm=3000; | |
+ str_rpm_max = psensor_value_to_str(SENSOR_TYPE_RPM, | |
+ max_rpm, false); | |
if (config_get_temperature_unit() == CELSIUS) | |
use_celsius = 1; | |
@@ -507,9 +511,11 @@ | |
use_celsius = 0; | |
mint = get_min_temp(enabled_sensors); | |
+ if (mint > 20) mint=20; | |
strmin = psensor_value_to_str(SENSOR_TYPE_TEMP, mint, use_celsius); | |
maxt = get_max_temp(enabled_sensors); | |
+ if (maxt < 100) maxt=100; | |
strmax = psensor_value_to_str(SENSOR_TYPE_TEMP, maxt, use_celsius); | |
et = get_graph_end_time_s(enabled_sensors); | |
@@ -538,6 +544,7 @@ | |
cairo_text_extents(cr, str_btime, &te_btime); | |
cairo_text_extents(cr, strmax, &te_max); | |
cairo_text_extents(cr, strmin, &te_min); | |
+ cairo_text_extents(cr, str_rpm_max, &te_rpm_max); | |
g_yoff = GRAPH_V_PADDING; | |
info.g_yoff = g_yoff; | |
@@ -642,6 +649,13 @@ | |
GRAPH_H_PADDING, height - (te_min.height / 2) - g_yoff); | |
cairo_show_text(cr, strmin); | |
free(strmin); | |
+ | |
+ /* draw max fan rpm on the right of the graph*/ | |
+ cairo_move_to(cr, | |
+ width - te_rpm_max.width - GRAPH_H_PADDING, | |
+ te_rpm_max.height + GRAPH_V_PADDING); | |
+ cairo_show_text(cr, str_rpm_max); | |
+ free(str_rpm_max); | |
cr_pixmap = gdk_cairo_create(gtk_widget_get_window(w_graph)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment