1 /* Conky, a system monitor, based on torsmo
3 * Please see COPYING for details
5 * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
6 * Copyright (c) 2009 Yeon-Hyeong Yang <lbird94@gmail.com>
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 /* conky support for information from sony_laptop kernel module
24 * information from sony_laptop kernel module
25 * /sys/devices/platform/sony-laptop
26 * I mimicked the methods from ibm.c
27 * Yeon-Hyeong Yang <lbird94@gmail.com> */
38 #define SONY_LAPTOP_DIR "/sys/devices/platform/sony-laptop"
40 /* fanspeed in SONY_LAPTOP_DIR contains an integer value for fanspeed (0~255).
41 * I don't know the exact measurement unit, though. I may assume that 0 for
42 * 'fan stopped' and 255 for 'maximum fan speed'. */
43 void get_sony_fanspeed(char *p_client_buffer, size_t client_buffer_size)
46 unsigned int speed = 0;
49 if (!p_client_buffer || client_buffer_size <= 0) {
53 snprintf(fan, 127, "%s/fanspeed", SONY_LAPTOP_DIR);
60 if (fgets(line, 255, fp) == NULL) {
63 if (sscanf(line, "%u", &speed)) {
68 CRIT_ERR(NULL, NULL, "can't open '%s': %s\nEnable sony support or remove "
69 "sony* from your "PACKAGE_NAME" config file.",
70 fan, strerror(errno));
74 snprintf(p_client_buffer, client_buffer_size, "%d", speed);