Modify

Opened 5 years ago

Last modified 2 years ago

#8679 new enhancement

hotplug 00-button script missing in WZR-HP-G300NH snapshot [r25032]

Reported by: anonymous Owned by: developers
Priority: normal Milestone: Chaos Calmer 15.05
Component: base system Version: Trunk
Keywords: Cc:

Description

base-files package does not contain hotplug.d/button/00-button script despite kmod-button-hotplug, kmod-input-gpio-buttons are installed by default.

This is an enhanced version of 00-button that blinks an user specified led at 1 sec intervals and log the handled event if succesful.

. /etc/functions.sh

do_button () {
	local button
	local led_counter
	local action
	local handler
	local min
	local max

	config_get button $1 button
	config_get led_counter $1 led_counter
	config_get action $1 action
	config_get handler $1 handler
	config_get min $1 min
	config_get max $1 max

[ -n "$led_counter" -a "$ACTION" != "$action" ] && {
		sleep 1
		echo "timer" > /sys/class/leds/${led_counter}/trigger
		echo 500 > /sys/class/leds/${led_counter}/delay_on
		echo 500 > /sys/class/leds/${led_counter}/delay_off
	}

	[ "$ACTION" = "$action" -a "$BUTTON" = "$button" -a -n "$handler" ] && {
		[ -n "$led_counter" ] && echo "none" > /sys/class/leds/${led_counter}/trigger
		[ -z "$min" -o -z "$max" ] && {
			eval $handler 
			logger "$BUTTON $ACTION: $SEEN sec. (handler: $handler)"
		}
		[ -n "$min" -a -n "$max" ] && {
			[ $min -le $SEEN -a $max -ge $SEEN ] && {
				eval $handler
				logger "$BUTTON $ACTION: $SEEN sec. (handler: $handler)"
			}
		}
	} 
}

config_load system
config_foreach do_button button

/etc/system entry for WZR-HP-G300NH button-handler is:

config 'button'
	option 'button' 'wps'
	option 'led_counter' 'wzr-hp-g300nh:red:diag'
	option 'action' 'released'
	option 'handler' '/usr/sbin/wifi-flip'
	option 'min' '0'
	option 'max' '2'

Attachments (1)

99-button (1.1 KB) - added by anonymous 5 years ago.
Disable blinking option if no handler is set and is not triggered by unrelated button

Download all attachments as: .zip

Change History (3)

comment:1 Changed 5 years ago by anonymous

This script supersedes the above button script which did not filter blinking for unrelated buttons

. /etc/functions.sh

do_button () {
	local button
	local led_counter
	local action
	local handler
	local min
	local max

	config_get button $1 button
	config_get led_counter $1 led_counter
	config_get action $1 action
	config_get handler $1 handler
	config_get min $1 min
	config_get max $1 max

[ -n "$led_counter" -a "$BUTTON" = "$button" -a "$ACTION" != "$action" ] && {
		sleep 1
		echo "timer" > /sys/class/leds/${led_counter}/trigger
		echo 500 > /sys/class/leds/${led_counter}/delay_on
		echo 500 > /sys/class/leds/${led_counter}/delay_off
	}

	[ "$ACTION" = "$action" -a "$BUTTON" = "$button" -a -n "$handler" ] && {
		[ -n "$led_counter" ] && echo "none" > /sys/class/leds/${led_counter}/trigger
		[ -z "$min" -o -z "$max" ] && {
			eval $handler 
			logger "$BUTTON $ACTION: $SEEN sec. (handler: $handler)"
		}
		[ -n "$min" -a -n "$max" ] && {
			[ $min -le $SEEN -a $max -ge $SEEN ] && {
				eval $handler
				logger "$BUTTON $ACTION: $SEEN sec. (handler: $handler)"
			}
		}
	} 
}

config_load system
config_foreach do_button button

Changed 5 years ago by anonymous

Disable blinking option if no handler is set and is not triggered by unrelated button

comment:2 Changed 2 years ago by jow

  • Milestone changed from Backfire 10.03.2 to Chaos Calmer (trunk)

Milestone Backfire 10.03.2 deleted

Add Comment

Modify Ticket

Action
as new .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.