Merge pull request #2432 from kbabioch/wifitoggle-empty-led

wifitoggle: Fix empty led_sysfs option
This commit is contained in:
Nuno Goncalves 2016-04-12 23:08:31 +01:00
commit a6dc7354f6
3 changed files with 8 additions and 3 deletions

View File

@ -1,6 +1,7 @@
#
# Copyright (C) 2010-2014 OpenWrt.org
# Copyright (C) 2010 segal.di.ubi.pt
# Copyright (C) 2016 Karol Babioch <karol@babioch.de>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@ -10,7 +11,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=wifitoggle
PKG_VERSION:=1
PKG_RELEASE:=4
PKG_RELEASE:=5
PKG_LICENSE:=GPL-2.0+
PKG_MAINTAINER:=Nuno Goncalves <nunojpg@gmail.com>

View File

@ -4,7 +4,9 @@ config wifitoggle
option persistent '0'
option timer '600'
option led_sysfs 'wrt160nl:amber:wps'
#option led_sysfs 'wrt160nl:amber:wps'
# Leaving this option empty, makes sure that no LED is touched
option led_sysfs ''
option led_enable_trigger 'timer'
option led_enable_delayon '500'
option led_enable_delayoff '500'

View File

@ -1,7 +1,9 @@
# /bin/sh
setled() {
if [ -e /sys/class/leds/${led_sysfs}/brightness ]
if [ -z "${led_sysfs}" ]; then
return
elif [ -e /sys/class/leds/${led_sysfs}/brightness ]
then
[ $led_default -eq 1 ] && echo 1 >/sys/class/leds/${led_sysfs}/brightness
[ $led_default -eq 1 ] || echo 0 >/sys/class/leds/${led_sysfs}/brightness