1 /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
3 * Conky, a system monitor, based on torsmo
5 * Please see COPYING for details
7 * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
8 * Copyright (c) 2009 Yeon-Hyeong Yang <lbird94@gmail.com>
10 * All rights reserved.
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * vim: ts=4 sw=4 noet ai cindent syntax=c
27 /* conky support for information from sony_laptop kernel module
28 * information from sony_laptop kernel module
29 * /sys/devices/platform/sony-laptop
30 * I mimicked the methods from ibm.c
31 * Yeon-Hyeong Yang <lbird94@gmail.com> */
42 #define SONY_LAPTOP_DIR "/sys/devices/platform/sony-laptop"
44 /* fanspeed in SONY_LAPTOP_DIR contains an integer value for fanspeed (0~255).
45 * I don't know the exact measurement unit, though. I may assume that 0 for
46 * 'fan stopped' and 255 for 'maximum fan speed'. */
47 void get_sony_fanspeed(char *p_client_buffer, size_t client_buffer_size)
50 unsigned int speed = 0;
53 if (!p_client_buffer || client_buffer_size <= 0) {
57 snprintf(fan, 127, "%s/fanspeed", SONY_LAPTOP_DIR);
64 if (fgets(line, 255, fp) == NULL) {
67 if (sscanf(line, "%u", &speed)) {
72 CRIT_ERR(NULL, NULL, "can't open '%s': %s\nEnable sony support or remove "
73 "sony* from your "PACKAGE_NAME" config file.",
74 fan, strerror(errno));
78 snprintf(p_client_buffer, client_buffer_size, "%d", speed);