Mercurial > audlegacy-plugins
comparison src/Visualization/rocklight/thinklight.c @ 0:13389e613d67 trunk
[svn] - initial import of audacious-plugins tree (lots to do)
| author | nenolod |
|---|---|
| date | Mon, 18 Sep 2006 01:11:49 -0700 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:13389e613d67 |
|---|---|
| 1 /*************************************************************************** | |
| 2 * thinklight.c | |
| 3 * | |
| 4 * Sun Dec 26 17:02:38 2004 | |
| 5 * Copyright 2004 Benedikt 'Hunz' Heinz | |
| 6 * rocklight@hunz.org | |
| 7 * $Id: thinklight.c,v 1.2 2005/03/26 21:29:17 hunz Exp $ | |
| 8 ****************************************************************************/ | |
| 9 | |
| 10 /* | |
| 11 * This program is free software; you can redistribute it and/or modify | |
| 12 * it under the terms of the GNU General Public License as published by | |
| 13 * the Free Software Foundation; either version 2 of the License, or | |
| 14 * (at your option) any later version. | |
| 15 * | |
| 16 * This program is distributed in the hope that it will be useful, | |
| 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 * GNU Library General Public License for more details. | |
| 20 * | |
| 21 * You should have received a copy of the GNU General Public License | |
| 22 * along with this program; if not, write to the Free Software | |
| 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
| 24 */ | |
| 25 | |
| 26 #include <sys/types.h> | |
| 27 #include <sys/stat.h> | |
| 28 #include <fcntl.h> | |
| 29 #include <unistd.h> | |
| 30 | |
| 31 int thinklight_open(void) { | |
| 32 return open("/proc/acpi/ibm/light",O_RDWR); | |
| 33 } | |
| 34 | |
| 35 void thinklight_close(int fd) { | |
| 36 close(fd); | |
| 37 } | |
| 38 | |
| 39 int thinklight_set(int fd, int state) { | |
| 40 return write(fd,state?"on\n":"off\n",state?3:4); | |
| 41 } | |
| 42 | |
| 43 int thinklight_get(int fd) { | |
| 44 char buf[256]; | |
| 45 int ret=read(fd,&buf,sizeof(buf)); | |
| 46 | |
| 47 if(ret<0) | |
| 48 return ret; | |
| 49 else if(ret<11) | |
| 50 return -23; | |
| 51 else if(buf[10]=='f') | |
| 52 return 0; | |
| 53 else if(buf[10]=='n') | |
| 54 return 1; | |
| 55 else | |
| 56 return -42; | |
| 57 } |
