Mercurial > audlegacy-plugins
diff src/rocklight/sysled.c @ 411:78a5e9c37469 trunk
[svn] - Rework and clean up code
- Add generic support for /sys/class/leds/ LEDs, used for Apple PMU and SMU
- Make rocklight configurable in configure
| author | hansmi |
|---|---|
| date | Sat, 06 Jan 2007 07:40:46 -0800 |
| parents | |
| children | ed2d7787779e |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rocklight/sysled.c Sat Jan 06 07:40:46 2007 -0800 @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2006 Tony Vroon <chainsaw@gentoo.org> + * Copyright (C) 2007 Michael Hanselmann <audacious@hansmi.ch> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <unistd.h> +#include <stdlib.h> + +#include "rocklight.h" + +int sysled_set(int fd, int state) { + if (state) { + return write(fd, "255\n", 4); + } else { + return write(fd, "0\n", 2); + } +} + +int sysled_get(int fd) { + char buf[256]; + int ret = read(fd, &buf, sizeof(buf)); + + return (strtol(buf, NULL, 10) == 255); +}
