KTemperature

System Software

Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net

0
5.0
Available as/for: -
Description:

KTemperature is an application to monitor the system temperature. I was motivated to develop this utility because I could not find a simple system tray resident application for monitoring the system temperature using the ACPI interface.

The application obtains the system temperature from the file /proc/acpi/thermal_zone/THRM/temperature .

I have been using Linux and Open Source for quite sometime and this is my first contribution. I hope this will lead to
many more contributions from me.

SuSE 9.2 rpm for the i686 platform is available for download.
The available rpm also works for SuSE 9.3.
The rpm available for download can be installed on SuSE 10.0 as well.
Last changelog:

15 years ago

Version 1.1
Added check for the presence of /proc/acpi/thermal_zone/THRM/temperature file. If the file is not present the temperature will be displayed as NA.

Version 1.2
Corrected typo.
Visual representation of the "hotness" of the system.
The system maximum temperature can be provided as an input. The system tray icon will change redness depending on the ratio of provided maximum temperature to the current temperature.

Version 1.3
Configurable temperature monitoring interface, can be anything as long as the temperature can be obtained by doing a read operation on the file.
Stored configuration. The configuration is stored in $HOME/.ktemperatue and read on startup.
Increased sensitivity of redness to temperature changes.

Version 1.4
Auto adjusting text font. The color of the text adjusts to a compliment of the background color, This ensures that the text is clearly visible irrespective of the redness of the systray icon.
More prominent text. The text is bold faced and the font of the text is bigger.

Version 1.5
Changes of parameters (polling interval and max, temperature) take instantaneous effect without having to restart the application.
Boundary values cases of redness, the calculation of redness difference between the background and the foreground has been modified to ensure a minimum difference.
Text alignment, the temperature text will be aligned in the middle both vertically and horizontally.

Version 1.6
Auto loading of the neccessary ACPI thermal module and its dependencies if, required. The root password is checked prior to loading the modules.
Detection of two variants of the thermal interface, namely
/proc/acpi/thermal_zone/THRM and
/proc/acpi/thermal_zone/THM

Version 1.7
The ACPI thermal interface was being detected by searching the /proc/modules file. However, that approach will lead to an irritating request for root password in cases where the module in compiled into the kernel. The thermal interface detection has been modified to take care of the above case.

Version 1.8
Added Pause, Restart and Update options in the right click menu for more control of polling.
Cleaned the auto detection of ACPI thermal interface. The first file in the thermal_zone directory(other than .. and .)is taken as the temperature file.
Fixed the width of the main window to be always greater than the width of widest child window.

Version 1.9
Changed the implementation of 'redness' from RGB space to HSV space for greater sensitivity.
The background color changes from green at minimum temperature to red at maximum temperature.
The text is always constant and will have a clear contrast all temperatures.
Replace memcpy with strcpy in monitor interface selection.
Interface(s) selected in the drop down list will be honoured when the Set button is clicked after the selection.
Used grid layout for the main widget.

Version 1.9-1
Created archive to include version information.
Added keyboard shortcuts to right click menu options.
Added caption to root password dialog.

I would like to acknowledge the suggestions that I have received. The changes have been made taking into account these suggestions.

kaigoth

15 years ago

getting the following errors...

ktemperaturewidget.cpp:57: error: `system' undeclared (first use this function)
ktemperaturewidget.cpp:57: error: (Each undeclared identifier is reported only
once for each function it appears in.)
ktemperaturewidget.cpp:74: error: `getenv' undeclared (first use this function)
ktemperaturewidget.cpp: In member function `void
KTemperatureWidget::checkTemperature()':
ktemperaturewidget.cpp:163: error: `atoi' undeclared (first use this function)

Report

fozerator

15 years ago

You should add the following line (after the include declarations) in the ./src/ktemperaturewidget.cpp file:

#include <stdlib.h>

Then try to compile once again....

Good luck,

James Kassemi

Report

vadimt

15 years ago

Please add version numbers to your source archives. The way it currently is complicates the creation of packages in some distributions.

For instance, Gentoo keeps md5 sums of the tar.gz files, and will refuse to install if it changes, which will happen when you release a new version.

Please name your archives like this:
ktemperature-1.9.tar.gz

And make sure you never change a file once released, as it will cause problems.

The archive should decompress into a directory that also includes the version number.

Once you do this, I will contribute a Gentoo ebuild and submit it to the Gentoo bug tracker.

Report

C

avasaralak

15 years ago

Thank you for the suggestion. Henceforth I will upload with the version number.

Report

maxxrad

15 years ago

I am getting the following error while compiling:

configure: error: We need a working libXext to proceed.

I had to execute the following to get it this far:

[root@lypo ktemperature]# ./configure --x-includes=/usr/X11R6/include/ --x-libraries=/usr/X11R6/lib/

how do I get it to find the libXext?? It is installed.
I am running Fedora Core 4

thanks

Report

C

avasaralak

15 years ago

Do you libXext.so or libXext.so.* ? If you do not have libXext.so, can you try creating a link libXext.so to libXext.so.* ?

Report

maxxrad

15 years ago

In my /usr/X11R6/lib I have a libXext.so.6.4 and a link to it that is libXext.so.6. Do I need to make just a libXext.so and link it to libXext.so.6?

Report

C

avasaralak

15 years ago

Try ln -s libXext.so.6 libXext.so.

Report

maxxrad

15 years ago

that didn't work.
any other ideas?

Report

C

avasaralak

15 years ago

Actually I have 2 links to libXext.so.6.4 namely
libXext.so and libXext.so.6
I tried configure removing each link and it failed after I removed the link from libXext.so.6 to libXext.so.6.4 complaining about kde-config returning a null path to kdelibs.
Do you kde-config insatlled ?

Report

blilly

15 years ago

1 when changing file source, the string isn't properly terminated. Patch:
*** src/ktemperaturewidget.cpp.orig Wed Jun 22 09:47:29 2005
--- src/ktemperaturewidget.cpp Wed Jun 22 09:47:37 2005
***************
*** 191,197 ****

void KTemperatureWidget::monitorInterfaceSelect_urlSelected(const QString& selectedInterface)
{
! memcpy(monitorInterface, selectedInterface.ascii(), selectedInterface.length());
}

/*!
--- 191,197 ----

void KTemperatureWidget::monitorInterfaceSelect_urlSelected(const QString& selectedInterface)
{
! memcpy(monitorInterface, selectedInterface.ascii(), selectedInterface.length()+1);
}

/*!

2. The right side of the "Open file dialog" button still seems to be cut off.

3. when changing file source, changes from the pull-down menu don't take effect. The open file dialog has to be used every time

4. Contrast is still very low ca. 48 C.
This probably can't be fixed satisfactorily in RGB space. I'll post a separate set of suggested patches to handle this issue in HSV space.

Report

blilly

15 years ago

The following patch changes the background color from low-saturation green at 37 C through yellow and orange to fully-saturated red at the maximum temperature (which can;t be set lower than 38 C to avoid divide-by-zero errors); below 37 C, the color becomes a progrssively more saturated blue.
Text is set for good contrast with the background.

(don't blame me for kde-apps.org screw-ups of patch text)

*** src/ktemperaturewidgetbase.ui.orig Wed Jun 22 11:04:29 2005
--- src/ktemperaturewidgetbase.ui Wed Jun 22 11:08:24 2005
***************
*** 126,132 ****
70


! 0


80
--- 126,132 ----
70


! 38


80
*** src/ktemperaturewidget.cpp.orig Wed Jun 22 10:47:44 2005
--- src/ktemperaturewidget.cpp Wed Jun 22 11:17:45 2005
***************
*** 91,97 ****
fclose(configFilePtr);
}
monitorInterfaceSelect->setProperty("url", monitorInterface);
- rednessStep = 255.0/(maxSysTemperature - 35.0);
pollTimer = new QTimer( this );
connect( pollTimer, SIGNAL(timeout()),this, SLOT(checkTemperature()));
pollTimer->start( pollIntreval * 1000 );
--- 91,96 ----
***************
*** 116,122 ****
pollTimer->start( pollIntreval * 1000 );

maxSysTemperature = sysMaxTempInput->value();
- rednessStep = 255.0/(maxSysTemperature - 35.0);

configFilePtr = fopen(configFile,"w");
if(configFilePtr == NULL)
--- 115,120 ----
***************
*** 141,148 ****
FILE* temperatureFile;
QColor sysTrayColor,textColor;
char temperatureString[32];
! int bgRed,fgRed;
!
//temperatureFile = fopen("/proc/acpi/thermal_zone/THRM/temperature","r");
temperatureFile = fopen(monitorInterface,"r");
if(temperatureFile == NULL)
--- 139,147 ----
FILE* temperatureFile;
QColor sysTrayColor,textColor;
char temperatureString[32];
! int temperature, hue, saturation, value, green_temp;
!
! green_temp = sysMaxTempInput->minValue() - 1;
//temperatureFile = fopen("/proc/acpi/thermal_zone/THRM/temperature","r");
temperatureFile = fopen(monitorInterface,"r");
if(temperatureFile == NULL)
***************
*** 154,178 ****
fscanf(temperatureFile,"%s",temperatureString);
fclose(temperatureFile);

! bgRed = (int)((atoi(temperatureString) - 35.0) * rednessStep);
! if(bgRed < 0)
! {
! bgRed = 0;
! }
! if(bgRed > 255)
! {
! bgRed = 255;
! }
!
! fgRed = 255 - bgRed;
!
! if((bgRed - fgRed) < 100)
! {
! fgRed = bgRed - 100;
! }
!
! sysTrayColor.setRgb(bgRed,255 - bgRed,255 - bgRed);
! textColor.setRgb(fgRed,255 - fgRed,255 - fgRed);
trayObject->setPaletteBackgroundColor (sysTrayColor);
trayObject->setPaletteForegroundColor(textColor);
trayObject->repaint();
--- 153,178 ----
fscanf(temperatureFile,"%s",temperatureString);
fclose(temperatureFile);

! temperature = atoi(temperatureString);
! hue = (maxSysTemperature - temperature) * 120 / (maxSysTemperature - green_temp); /* green at green_temp, red at maxSysTemperature */
! if (hue < 0)
! hue = 0; /* red */
! if (hue > 240)
! hue = 240; /* blue */
! #define MINSAT 100
! saturation = MINSAT + abs((255 - MINSAT) * (temperature - green_temp) / (maxSysTemperature - green_temp)); /* minimum at green_temp, fully saturated at maxSysTemperature */
! if (saturation > 255)
! saturation = 255;
! if (saturation < MINSAT)
! saturation = MINSAT;
!
! sysTrayColor.setHsv(hue,saturation,255);
! if (hue 127? 0: 255);
trayObject->setPaletteBackgroundColor (sysTrayColor);
trayObject->setPaletteForegroundColor(textColor);
trayObject->repaint();

Report

rickvernam

15 years ago

first, this is very complimentary to my laptop, it is a portable space heater as much as it is a laptop!

Anyway...an option in the right-click menu to 'update now' would be nice.

Report

C

avasaralak

15 years ago

Added Pause, Restart and Update options to the right click menu.

Report

blilly

15 years ago

Thanks for listening.

However, there's still a problem: consider what happens when (under defaults) the temperature is 52 C.
red = 123, green = blue = 132. Text
is R=132, G=B=123; very low contrast.
Ideally, you'd want to work in HSV,
with complementary hue, similar saturation, and widely different value.

Also, now the text is too big; it's clipped after the first digit.

And one more issue is that changes made in the dialog box don;t take effect until ktemperature is quit and restarted.

A quick hack for the first two issues (black text on light background, white on dark) and a fix for the third is:

*** src/ktemperaturewidget.cpp.original Mon Jun 6 13:56:17 2005
--- src/ktemperaturewidget.cpp Mon Jun 6 14:17:11 2005
***************
*** 87,92 ****
--- 87,94 ----
{
fprintf(configFilePtr,"%d %d %s",pollIntreval,maxSysTemperature,monitorInterface);
fclose(configFilePtr);
+ rednessStep = 255.0/(maxSysTemperature - 35.0);
+ pollTimer->start( pollIntreval * 1000 );
}
hide();
}
***************
*** 106,112 ****
FILE* temperatureFile;
QColor sysTrayColor,textColor;
char temperatureString[32];
! int red,blue,green;

//temperatureFile = fopen("/proc/acpi/thermal_zone/THRM/temperature","r");
temperatureFile = fopen(monitorInterface,"r");
--- 108,114 ----
FILE* temperatureFile;
QColor sysTrayColor,textColor;
char temperatureString[32];
! int red,blue,green, v;

//temperatureFile = fopen("/proc/acpi/thermal_zone/THRM/temperature","r");
temperatureFile = fopen(monitorInterface,"r");
***************
*** 132,138 ****
blue = 255 - red;

sysTrayColor.setRgb(red,blue,green);
! textColor.setRgb(255 - red,255 - green,255 - blue);
trayObject->setPaletteBackgroundColor (sysTrayColor);
trayObject->setPaletteForegroundColor(textColor);
trayObject->repaint();
--- 134,144 ----
blue = 255 - red;

sysTrayColor.setRgb(red,blue,green);
! v = (red * 29 + green * 59 + blue * 11) / 100;
! if (v >=128)
! textColor.setRgb(0,0,0);
! else
! textColor.setRgb(255,255,255);
trayObject->setPaletteBackgroundColor (sysTrayColor);
trayObject->setPaletteForegroundColor(textColor);
trayObject->repaint();
*** src/main.cpp.original Mon Jun 6 14:11:04 2005
--- src/main.cpp Mon Jun 6 14:12:38 2005
***************
*** 48,54 ****
KApplication app;
KTemperatureWidget *mainWin = 0;
KSystemTray *systemTray = 0;
! QFont sysTrayFont("Times New Roman", 20, QFont::Bold);
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

/// @todo do something with the command line args here
--- 48,54 ----
KApplication app;
KTemperatureWidget *mainWin = 0;
KSystemTray *systemTray = 0;
! QFont sysTrayFont("Times New Roman", 16, QFont::Bold);
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

/// @todo do something with the command line args here

Report

C

avasaralak

15 years ago

Good catch. I overlooked the case since my laptop runs quite hot (always around 60), hence everything was ok for me. Will quite certainly incorporate the changes.

Report

blilly

15 years ago

1. change text color for good contrast with the background. Dark text on a dark background isn't very legible

2. maybe add graphing capability (e.g. like knemo has)

Report

C

avasaralak

15 years ago

Since the background color of the system tray changes depending on the system temperature, I think there is no one color that will be consistently visible all the time. However, I will try to make the text bolder.

Report

krionius

15 years ago

Great work. I tried it, and it works well.
One little upgrade could be, if you make it start a resident child process, so when i close konsole, it wont stop the program running. (Especially, because it it an application that is for the task bar.)

Anyway, I like it very much, because ksensors is much depreceted, and more complicated to install.

Congrats!

Report

C

avasaralak

15 years ago

If you do a make install as root, it shows up in the Utilities submenu of the KDE menu. If you do not want to do a make install as root, you can try nohup ktemperature & . This way it will stay resident even if you close the console.

Report

krionius

15 years ago

you are right, i knew the option. unix style process handling rules. But it still would be nice, if you implement in a later version, if its not a big thing. Otherwise dont worry about it.

Your app is cool. I was not aware that my AMD CPU get so hot while converting movies... its near 70 Celsius degree. :)

Report

SWaN

15 years ago

With Slackware I get this error:

ktemperature
libpng error: Not a PNG file
libpng error: Not a PNG file
KCrash: Application 'ktemperature' crashing...

Any hint?

Report

krionius

15 years ago

I also have the message, but it doesnt actually crash!

Report

Deltaflyer

15 years ago

I also get this errors,
I think the problem is, that the .png files in the src directory arn't real png files.
I can't opem them with kuickshow and file say :
hi16-app-ktemperature.png: data
hi32-app-ktemperature.png: data

Report

C

avasaralak

15 years ago

I am also getting the PNG error. However, when I run the application it is not crashing.
Do you have the temperature interface at
/proc/acpi/thermal_zone/THRM/temperature ?
I don't think there is a check for the status of the file open in the current version.

Report

15 years ago

Version 1.1
Added check for the presence of /proc/acpi/thermal_zone/THRM/temperature file. If the file is not present the temperature will be displayed as NA.

Version 1.2
Corrected typo.
Visual representation of the "hotness" of the system.
The system maximum temperature can be provided as an input. The system tray icon will change redness depending on the ratio of provided maximum temperature to the current temperature.

Version 1.3
Configurable temperature monitoring interface, can be anything as long as the temperature can be obtained by doing a read operation on the file.
Stored configuration. The configuration is stored in $HOME/.ktemperatue and read on startup.
Increased sensitivity of redness to temperature changes.

Version 1.4
Auto adjusting text font. The color of the text adjusts to a compliment of the background color, This ensures that the text is clearly visible irrespective of the redness of the systray icon.
More prominent text. The text is bold faced and the font of the text is bigger.

Version 1.5
Changes of parameters (polling interval and max, temperature) take instantaneous effect without having to restart the application.
Boundary values cases of redness, the calculation of redness difference between the background and the foreground has been modified to ensure a minimum difference.
Text alignment, the temperature text will be aligned in the middle both vertically and horizontally.

Version 1.6
Auto loading of the neccessary ACPI thermal module and its dependencies if, required. The root password is checked prior to loading the modules.
Detection of two variants of the thermal interface, namely
/proc/acpi/thermal_zone/THRM and
/proc/acpi/thermal_zone/THM

Version 1.7
The ACPI thermal interface was being detected by searching the /proc/modules file. However, that approach will lead to an irritating request for root password in cases where the module in compiled into the kernel. The thermal interface detection has been modified to take care of the above case.

Version 1.8
Added Pause, Restart and Update options in the right click menu for more control of polling.
Cleaned the auto detection of ACPI thermal interface. The first file in the thermal_zone directory(other than .. and .)is taken as the temperature file.
Fixed the width of the main window to be always greater than the width of widest child window.

Version 1.9
Changed the implementation of 'redness' from RGB space to HSV space for greater sensitivity.
The background color changes from green at minimum temperature to red at maximum temperature.
The text is always constant and will have a clear contrast all temperatures.
Replace memcpy with strcpy in monitor interface selection.
Interface(s) selected in the drop down list will be honoured when the Set button is clicked after the selection.
Used grid layout for the main widget.

Version 1.9-1
Created archive to include version information.
Added keyboard shortcuts to right click menu options.
Added caption to root password dialog.

I would like to acknowledge the suggestions that I have received. The changes have been made taking into account these suggestions.

12345678910
Be the first to comment
File (click to download) Version Description PackagetypeArchitectureRelease ChannelDevices Downloads Date Filesize DL OCS-Install MD5SUM
*Needs pling-store or ocs-url to install things
Pling
0 Affiliates
Details
license
version
1.9
updated Oct 09 2005
added May 26 2005
downloads 24h
0
mediaviews 24h 0
pageviews 24h 0
System Tags app software