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