mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-02-10 16:08:31 +00:00
Missing files, fix last commit.
Added sony.[ch] stuff, as well as the important change from commit 3dd1738fb9e16831166e70201078164d551c7ffc
This commit is contained in:
parent
f6fe653401
commit
0d31ff0f4f
@ -2545,7 +2545,7 @@ static struct text_object *construct_text_object(const char *s,
|
|||||||
}else if(arg[i] == '}') {
|
}else if(arg[i] == '}') {
|
||||||
indenting--;
|
indenting--;
|
||||||
}
|
}
|
||||||
if(indenting == 0 && (arg[i+1] == ' ' || arg[i+1] == '$' || arg[i+1] == 0)) {
|
if (indenting == 0 && arg[i+1] < 48) { //<48 has 0, $, and the most used chars not used in varnames but not { or }
|
||||||
endvar[j]=i+1;
|
endvar[j]=i+1;
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
54
src/sony.c
Normal file
54
src/sony.c
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/* conky support for information from sony_laptop kernel module
|
||||||
|
* information from sony_laptop kernel module
|
||||||
|
* /sys/devices/platform/sony-laptop
|
||||||
|
* I mimicked the methods from ibm.c
|
||||||
|
* Yeon-Hyeong Yang <lbird94@gmail.com> */
|
||||||
|
|
||||||
|
#include "conky.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "sony.h"
|
||||||
|
#include "logging.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define SONY_LAPTOP_DIR "/sys/devices/platform/sony-laptop"
|
||||||
|
|
||||||
|
/* fanspeed in SONY_LAPTOP_DIR contains an integer value for fanspeed (0~255).
|
||||||
|
* I don't know the exact measurement unit, though. I may assume that 0 for
|
||||||
|
* 'fan stopped' and 255 for 'maximum fan speed'. */
|
||||||
|
void get_sony_fanspeed(char *p_client_buffer, size_t client_buffer_size)
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
unsigned int speed = 0;
|
||||||
|
char fan[128];
|
||||||
|
|
||||||
|
if (!p_client_buffer || client_buffer_size <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(fan, 127, "%s/fanspeed", SONY_LAPTOP_DIR);
|
||||||
|
|
||||||
|
fp = fopen(fan, "r");
|
||||||
|
if (fp != NULL) {
|
||||||
|
while (!feof(fp)) {
|
||||||
|
char line[256];
|
||||||
|
|
||||||
|
if (fgets(line, 255, fp) == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (sscanf(line, "%u", &speed)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CRIT_ERR("can't open '%s': %s\nEnable sony support or remove "
|
||||||
|
"sony* from your "PACKAGE_NAME" config file.",
|
||||||
|
fan, strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
snprintf(p_client_buffer, client_buffer_size, "%d", speed);
|
||||||
|
}
|
||||||
|
|
14
src/sony.h
Normal file
14
src/sony.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/* conky support for information from sony_laptop kernel module
|
||||||
|
* information from sony_laptop kernel module
|
||||||
|
* /sys/devices/platform/sony-laptop
|
||||||
|
* I mimicked the methods from ibm.c
|
||||||
|
* Yeon-Hyeong Yang <lbird94@gmail.com> */
|
||||||
|
|
||||||
|
#ifndef _SONY_H
|
||||||
|
#define _SONY_H
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
void get_sony_fanspeed(char *buf, size_t client_buffer_size);
|
||||||
|
|
||||||
|
#endif /* _SONY_H */
|
Loading…
x
Reference in New Issue
Block a user