Missing files, fix last commit.
authorBrenden Matthews <brenden@rty.ca>
Mon, 4 May 2009 19:15:46 +0000 (13:15 -0600)
committerBrenden Matthews <brenden@rty.ca>
Mon, 4 May 2009 19:15:46 +0000 (13:15 -0600)
Added sony.[ch] stuff, as well as the important change from commit
3dd1738fb9e16831166e70201078164d551c7ffc

src/conky.c
src/sony.c [new file with mode: 0644]
src/sony.h [new file with mode: 0644]

index 6379d8a..3be9d86 100644 (file)
@@ -2545,7 +2545,7 @@ static struct text_object *construct_text_object(const char *s,
                                        }else if(arg[i] == '}') {
                                                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;
                                                j++;
                                        }
diff --git a/src/sony.c b/src/sony.c
new file mode 100644 (file)
index 0000000..3ee01f8
--- /dev/null
@@ -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);
+}
+
diff --git a/src/sony.h b/src/sony.h
new file mode 100644 (file)
index 0000000..3ce0af1
--- /dev/null
@@ -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 */