mirror of
https://github.com/gryf/wmtemp.git
synced 2026-05-10 16:33:03 +02:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fc28caa211 | |||
| fb2374178c | |||
| d029966151 | |||
| 85bd74b4f5 | |||
| e707cf4d33 | |||
| c8ac94080c | |||
| 53e3358e73 | |||
| 4e3058820d | |||
| ac503a1ee5 | |||
| 4e92b6f5ca | |||
| 0c442e8e90 | |||
| 28d2a7fd2e |
@@ -1,4 +1,4 @@
|
||||
This is dead simple Windo Wmaker app for monitoring CPU and GPU temperature.
|
||||
This is dead simple Window Wmaker app for monitoring CPU and GPU temperature.
|
||||
Hardcoded Core2 and Nvidia GPU support. Based on WMTempMon dockapp.
|
||||
|
||||
author: roman.dobosz@gmail.com
|
||||
Depends on lmsensors and optionally on nvidia-settings packages.
|
||||
|
||||
@@ -366,7 +366,7 @@ void setMaskXY(int x, int y) {
|
||||
/*******************************************************************************\
|
||||
|* openXwindow *|
|
||||
\*******************************************************************************/
|
||||
void openXwindow(int argc, char *argv[], char *pixmap_bytes[], char *pixmask_bits, int pixmask_width, int pixmask_height) {
|
||||
void openXwindow(int argc, char *argv[], char *pixmap_bytes[], const char *pixmask_bits, int pixmask_width, int pixmask_height) {
|
||||
|
||||
unsigned int borderwidth = 1;
|
||||
XClassHint classHint;
|
||||
|
||||
@@ -45,7 +45,7 @@ Display *display;
|
||||
void AddMouseRegion(int index, int left, int top, int right, int bottom);
|
||||
int CheckMouseRegion(int x, int y);
|
||||
|
||||
void openXwindow(int argc, char *argv[], char **, char *, int, int);
|
||||
void openXwindow(int argc, char *argv[], char **, const char *, int, int);
|
||||
void RedrawWindow(void);
|
||||
void RedrawWindowXY(int x, int y);
|
||||
|
||||
|
||||
+63
-65
@@ -2,11 +2,10 @@
|
||||
* wmtempnv: a sensor monitor for WindowMaker. this little app is mainly based
|
||||
* on wmsensormon and other simple dockapps.
|
||||
*
|
||||
* version = 0.1
|
||||
* date: Fri Oct 31 20:41:14 CET 2008 @861 /Internet Time/
|
||||
* author: Roman 'gryf' Dobosz
|
||||
* requirements: configured lm_sensors and sensor program, nvidia-settings, cut,
|
||||
* grep.
|
||||
* version = 0.4
|
||||
*
|
||||
* requirements: configured lm_sensors, sensor program and nouveau
|
||||
*
|
||||
* licence: gpl
|
||||
*/
|
||||
|
||||
@@ -34,64 +33,63 @@ int get_offset(int temp, int cpu);
|
||||
|
||||
int main(int argc, char **argv){
|
||||
int temp1=0, temp2=0, temp3=0;
|
||||
/* offset is one of 0 (normal), 7 (alert), 14 (warning) */
|
||||
/* offset is one of 0 (normal), 7 (alert), 14 (warning) */
|
||||
int offset1=0, offset2=0, offset3=0;
|
||||
int counter = 0;
|
||||
int counter = 0;
|
||||
|
||||
openXwindow(argc, argv, wmtempnv_master2_xpm, wmtempnv_mask_bits, wmtempnv_mask_width, wmtempnv_mask_height);
|
||||
|
||||
while(TRUE){
|
||||
if(counter==0){
|
||||
temp1 = get_temp(0);
|
||||
offset1 = get_offset(temp1, 1);
|
||||
temp2 = get_temp(1);
|
||||
offset2 = get_offset(temp2, 1);
|
||||
temp3 = get_temp(2);
|
||||
offset3 = get_offset(temp3, 0);
|
||||
counter = 200;
|
||||
}
|
||||
while(TRUE){
|
||||
if(counter==0){
|
||||
temp1 = get_temp(0);
|
||||
offset1 = get_offset(temp1, 1);
|
||||
temp2 = get_temp(1);
|
||||
offset2 = get_offset(temp2, 1);
|
||||
temp3 = get_temp(2) / 1000;
|
||||
offset3 = get_offset(temp3, 0);
|
||||
counter = 200;
|
||||
}
|
||||
|
||||
// core 1
|
||||
copyXPMArea(0, 87 + offset1, 23, 7, 4, 7); // LCD: "CPU"
|
||||
copyXPMArea(69, 87 + offset1, 5, 7, 22, 7); // LCD: number of cpu
|
||||
copyXPMArea(66, 65 + offset1, 9, 7, 51, 7); // LCD: "°C"
|
||||
display_values(temp1, 0, offset1);
|
||||
// core 1
|
||||
copyXPMArea(0, 87 + offset1, 23, 7, 4, 7); // LCD: "CPU"
|
||||
copyXPMArea(69, 87 + offset1, 5, 7, 22, 7); // LCD: number of cpu
|
||||
copyXPMArea(66, 65 + offset1, 9, 7, 51, 7); // LCD: "°C"
|
||||
display_values(temp1, 0, offset1);
|
||||
|
||||
// core 2
|
||||
copyXPMArea(0, 87 + offset2, 23, 7, 4, 21);
|
||||
copyXPMArea(75, 87 + offset2, 5, 7, 22, 21);
|
||||
copyXPMArea(66, 65 + offset2, 9, 7, 51, 21);
|
||||
display_values(temp2, 14, offset2);
|
||||
// core 2
|
||||
copyXPMArea(0, 87 + offset2, 23, 7, 4, 21);
|
||||
copyXPMArea(75, 87 + offset2, 5, 7, 22, 21);
|
||||
copyXPMArea(66, 65 + offset2, 9, 7, 51, 21);
|
||||
display_values(temp2, 14, offset2);
|
||||
|
||||
// gpu
|
||||
copyXPMArea(23, 87 + offset3, 23, 7, 4, 35);
|
||||
copyXPMArea(66, 65 + offset3, 9, 7, 51, 35);
|
||||
display_values(temp3, 28, offset3);
|
||||
RedrawWindow();
|
||||
counter--;
|
||||
usleep(5000);
|
||||
}
|
||||
// gpu
|
||||
copyXPMArea(23, 87 + offset3, 23, 7, 4, 35);
|
||||
copyXPMArea(66, 65 + offset3, 9, 7, 51, 35);
|
||||
display_values(temp3, 28, offset3);
|
||||
RedrawWindow();
|
||||
counter--;
|
||||
usleep(5000);
|
||||
}
|
||||
}
|
||||
|
||||
int get_offset(int temp, int cpu){
|
||||
int alt, wrn;
|
||||
if(cpu == 1){
|
||||
wrn = TEMP;
|
||||
alt = TEMP_OVER;
|
||||
}else{
|
||||
wrn = GPU_T;
|
||||
alt = GPU_T_OVER;
|
||||
}
|
||||
if(temp >= alt){
|
||||
return 7; // Alert
|
||||
}else if(temp >= wrn){
|
||||
return 14; // Warning
|
||||
}else{
|
||||
return 0; // Normal
|
||||
}
|
||||
int alt, wrn;
|
||||
if(cpu == 1){
|
||||
wrn = TEMP;
|
||||
alt = TEMP_OVER;
|
||||
}else{
|
||||
wrn = GPU_T;
|
||||
alt = GPU_T_OVER;
|
||||
}
|
||||
if(temp >= alt){
|
||||
return 7; // Alert
|
||||
}else if(temp >= wrn){
|
||||
return 14; // Warning
|
||||
}else{
|
||||
return 0; // Normal
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void display_values(int temp, int offset, int offset2){
|
||||
char text[5], num1, num2, num3, num4;
|
||||
|
||||
@@ -101,34 +99,34 @@ void display_values(int temp, int offset, int offset2){
|
||||
num3 = (text[2] - '0');
|
||||
num4 = (text[3] - '0');
|
||||
if(num1)
|
||||
copyXPMArea(5 * num1, 65 + offset2, 5, 7, 31, 7 + offset);
|
||||
copyXPMArea(5 * num1, 65 + offset2, 5, 7, 31, 7 + offset);
|
||||
else
|
||||
copyXPMArea(60, 65 + offset2, 5, 7, 31, 7 + offset);
|
||||
copyXPMArea(60, 65 + offset2, 5, 7, 31, 7 + offset);
|
||||
copyXPMArea(5 * num2, 65 + offset2, 5, 7, 38, 7 + offset);
|
||||
copyXPMArea(5 * num3, 65 + offset2, 5, 7, 45, 7 + offset);
|
||||
copyXPMArea(5 * num4, 65 + offset2, 5, 7, 51, 7 + offset);
|
||||
}
|
||||
|
||||
int get_temp(int core_number){
|
||||
// Core temperature. argument is core number. core no.2 is GPU
|
||||
FILE *file;
|
||||
int core=0;
|
||||
char cmd[] = " ";
|
||||
if(core_number==2){
|
||||
sprintf(cmd, "echo `nvidia-settings -q 'GPUCoreTemp'|grep Attribute|cut -d ':' -f 3|cut -d '.' -f 1`");
|
||||
}else{
|
||||
sprintf(cmd, "echo `sensors |grep 'Core %d'|cut -d ':' -f 2|cut -d '.' -f 1`", core_number);
|
||||
}
|
||||
// Core temperature. argument is core number. core no.2 is GPU
|
||||
FILE *file;
|
||||
int core=0;
|
||||
char cmd[] = " ";
|
||||
if(core_number==2){
|
||||
sprintf(cmd, "echo `cat /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/hwmon/hwmon0/temp1_input`");
|
||||
}else{
|
||||
sprintf(cmd, "echo `sensors |grep 'Core %d'|cut -d ':' -f 2|cut -d '.' -f 1`", core_number);
|
||||
}
|
||||
file = popen(cmd, "r");
|
||||
while (! feof(file)) {
|
||||
char line[MAXSTRLEN + 1];
|
||||
bzero(line, MAXSTRLEN + 1);
|
||||
fgets(line, MAXSTRLEN, file);
|
||||
if(line[0] != 0){
|
||||
sscanf(line, "%d", &core);
|
||||
sscanf(line, "%d", &core);
|
||||
}
|
||||
}
|
||||
pclose(file);
|
||||
pclose(file);
|
||||
|
||||
return core;
|
||||
return core;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#define wmtempnv_mask_width 64
|
||||
#define wmtempnv_mask_height 64
|
||||
static unsigned char wmtempnv_mask_bits[] = {
|
||||
static const char wmtempnv_mask_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
Reference in New Issue
Block a user