mirror of
https://github.com/gryf/wmtemp.git
synced 2026-05-10 16:33:03 +02:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fc28caa211 | |||
| fb2374178c | |||
| d029966151 | |||
| 85bd74b4f5 | |||
| e707cf4d33 | |||
| c8ac94080c | |||
| 53e3358e73 | |||
| 4e3058820d |
@@ -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.
|
||||
|
||||
+2
-2
@@ -9,14 +9,14 @@ OBJ = $(SRC:.c=.o)
|
||||
|
||||
CFLAGS = -Wall -O3
|
||||
|
||||
LIB = -I/usr/include/NVCtrl/ -L/usr/X11R6/lib -lXpm -lXext -lX11 -lsensors -lXNVCtrl
|
||||
LIB = -L/usr/X11R6/lib -lXpm -lXext -lX11 -lsensors
|
||||
|
||||
INSTALL = /usr/bin/install
|
||||
|
||||
CC = gcc
|
||||
|
||||
all: $(OBJ)
|
||||
$(CC) $(CFLAGS) -o $(EXE) $(OBJ) $(LIB)
|
||||
$(CC) -o $(EXE) $(OBJ) $(LIB)
|
||||
strip $(EXE)
|
||||
|
||||
$(OBJ): %.o : %.c
|
||||
|
||||
+31
-41
@@ -4,8 +4,8 @@
|
||||
*
|
||||
* version = 0.4
|
||||
*
|
||||
* requirements: configured lm_sensors, sensor program and
|
||||
* nvidia-settings package
|
||||
* requirements: configured lm_sensors, sensor program and nouveau
|
||||
*
|
||||
* licence: gpl
|
||||
*/
|
||||
|
||||
@@ -18,42 +18,37 @@
|
||||
#include <string.h>
|
||||
#include "../wmgeneral/wmgeneral.h"
|
||||
#include "../wmgeneral/misc.h"
|
||||
#include "../wmgeneral/misc.h"
|
||||
#include "wmtempnv_master2.xpm"
|
||||
#include "wmtempnv_mask.xbm"
|
||||
|
||||
#include <NVCtrl/NVCtrl.h>
|
||||
#include <NVCtrl/NVCtrlLib.h>
|
||||
|
||||
#define MAXSTRLEN 8
|
||||
#define TEMP 40
|
||||
#define TEMP_OVER 47
|
||||
#define GPU_T 70
|
||||
#define GPU_T_OVER 85
|
||||
#define MAXFNAME 50
|
||||
|
||||
void display_values(int, int, int);
|
||||
int get_temp(int core_number, Display*);
|
||||
int get_temp(int core_number);
|
||||
int get_offset(int temp, int cpu);
|
||||
Display *display;
|
||||
|
||||
int main(int argc, char **argv){
|
||||
int temp1=0, temp2=0, temp3=0;
|
||||
/* offset is one of 0 (normal), 7 (alert), 14 (warning) */
|
||||
int offset1=0, offset2=0, offset3=0;
|
||||
int counter = 0;
|
||||
display = XOpenDisplay(NULL);
|
||||
|
||||
openXwindow(argc, argv, wmtempnv_master2_xpm, wmtempnv_mask_bits,
|
||||
wmtempnv_mask_width, wmtempnv_mask_height);
|
||||
openXwindow(argc, argv, wmtempnv_master2_xpm, wmtempnv_mask_bits, wmtempnv_mask_width, wmtempnv_mask_height);
|
||||
|
||||
while(TRUE){
|
||||
temp1 = get_temp(0, display);
|
||||
offset1 = get_offset(temp1, 1);
|
||||
temp2 = get_temp(1, display);
|
||||
offset2 = get_offset(temp2, 1);
|
||||
temp3 = get_temp(2, display);
|
||||
offset3 = get_offset(temp3, 0);
|
||||
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"
|
||||
@@ -73,7 +68,7 @@ int main(int argc, char **argv){
|
||||
display_values(temp3, 28, offset3);
|
||||
RedrawWindow();
|
||||
counter--;
|
||||
sleep(1);
|
||||
usleep(5000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,31 +107,26 @@ void display_values(int temp, int offset, int offset2){
|
||||
copyXPMArea(5 * num4, 65 + offset2, 5, 7, 51, 7 + offset);
|
||||
}
|
||||
|
||||
int get_temp(int core_number, Display *disp){
|
||||
int get_temp(int core_number){
|
||||
// Core temperature. argument is core number. core no.2 is GPU
|
||||
FILE *file;
|
||||
char filename[MAXFNAME];
|
||||
int core_temp = 0;
|
||||
Bool res;
|
||||
|
||||
if(core_number == 2){
|
||||
|
||||
res = XNVCTRLQueryTargetAttribute(disp,
|
||||
NV_CTRL_TARGET_TYPE_GPU, 0, 0,
|
||||
NV_CTRL_GPU_CORE_TEMPERATURE, &core_temp);
|
||||
|
||||
if (res == False) core_temp = 0;
|
||||
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{
|
||||
snprintf(filename, MAXFNAME,
|
||||
"/sys/bus/platform/devices/coretemp.0/temp%d_input",
|
||||
core_number + 2);
|
||||
if((file = fopen(filename, "r")) != NULL){
|
||||
if(fscanf(file, "%d", &core_temp) != EOF){
|
||||
core_temp = core_temp / 1000;
|
||||
fclose(file);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
return core_temp;
|
||||
}
|
||||
pclose(file);
|
||||
|
||||
return core;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user