# Increase the backlight level by one degree
# Bind this to a key of your choice
DestroyFunc IncreaseBacklightFunc
AddToFunc IncreaseBacklightFunc
+ I PipeRead `a=$[apm.backlight] ; test $a -lt 6 && a=$[a+1] ; setfl $a ; echo "Setenv apm.backlight $a"
+ I PipeRead `echo "Setenv apm.backlight $[apm.backlight]" > $./backlight.$[apm.status]`
#+ I ShowInfoMessage "Backlight: $[apm.backlight]" backlight.png "Backlight"

# Decrease the backlight level by one degree
# Bind this to a key of your choice
DestroyFunc DecreaseBacklightFunc
AddToFunc DecreaseBacklightFunc
+ I PipeRead `a=$[apm.backlight] ; test $a -gt 0 && a=$[a-1] ; setfl $a ; echo "Setenv apm.backlight $a"
+ I PipeRead `echo "Setenv apm.backlight $[apm.backlight]" > $./backlight.$[apm.status]`
#+ I ShowInfoMessage "Backlight: $[apm.backlight]" backlight.png "Backlight"

# Function to execute when the battery percentage changes
DestroyFunc BatteryFunc
AddToFunc BatteryFunc
+ I Setenv apm.msg "Offline, Battery status: $[apm.battery_percentage]%"

# Function to execute when the battery percentage changes by
# a certain amount of percentage
DestroyFunc BatteryIFunc
AddToFunc BatteryIFunc
+ I Setenv apm.icon fvwmapmdaemon/battery_$[apm.battery_interval_percentage].png
#+ I SendToModule FvwmPanel ChangeButton apm Title ""
#+ I SendToModule FvwmPanel ChangeButton apm Icon $[apm.icon]

# Function to execute when the ac adapter is unplugged
DestroyFunc OfflineFunc
AddToFunc OfflineFunc
+ I Read $./backlight.offline
+ I Exec `exec setfl $[apm.backlight]`
+ I Setenv apm.status offline

# Function to execute when the ac adapter is plugged
DestroyFunc ACFunc
AddToFunc ACFunc
+ I Setenv apm.msg "Online, charging"
#+ I Setenv apm.icon fvwmapmdaemon/power.png
#+ I ClearMessage
#+ I SendToModule FvwmPanel ChangeButton apm Icon $[apm.icon]
+ I Read $./backlight.online
+ I Exec `exec setfl $[apm.backlight]`
+ I Setenv apm.status online

DestroyFunc APMInfoFunc
AddToFunc APMInfoFunc
#+ I ShowInfoMessage "$[apm.msg]" "$[apm.icon]" "APM Status"

*FvwmAPMDaemon: APMWarnThreshold 12
*FvwmAPMDaemon: APMCriticalThreshold 8
#*FvwmAPMDaemon: APMWarnCommand ShowWarning "Battery level low!"
#*FvwmAPMDaemon: APMCriticalCommand ShowCriticalMessage "Battery level critical!"
*FvwmAPMDaemon: ACCommand ACFunc
*FvwmAPMDaemon: OfflineCommand OfflineFunc
*FvwmAPMDaemon: BatteryIPercentageBase 10
*FvwmAPMDaemon: BatteryICommand BatteryIFunc
*FvwmAPMDaemon: BatteryCommand BatteryFunc
# To have a status at startup
Setenv apm.status offline
# This should immediatly be overwritten when FvwmAPMDaemon
# is start up
Setenv apm.backlight 4