2 # Copyright 2009 Nicolas Bigaouette
3 # This file is part of acpi-eeepc-generic.
4 # http://code.google.com/p/acpi-eeepc-generic/
6 # acpi-eeepc-generic is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # acpi-eeepc-generic is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with acpi-eeepc-generic. If not, see <http://www.gnu.org/licenses/>.
20 .
/etc
/acpi
/eeepc
/acpi-eeepc-generic-functions.sh
22 .
/etc
/acpi
/eeepc
/models
/acpi-eeepc-defaults-events.conf
23 .
/etc
/acpi
/eeepc
/models
/acpi-eeepc-
$EEEPC_MODEL-events.conf
26 if [ "$KEY_SHOW" = "1" ]; then
27 eeepc_notify
"The event of the pressed key is: \"$SELECTION\"" keyboard
20000
38 00000000) # AC unplugged
39 # These events are generated twice (at least on the 1000)
40 # Make sure the commands are executed only once
41 if [ ! -e ${EEEPC_VAR}/ac_event_unplugged
]; then
42 touch ${EEEPC_VAR}/ac_event_unplugged
43 # Wait 5 seconds (in background) before deleting the file
44 echo `sleep 5 && rm -f ${EEEPC_VAR}/ac_event_unplugged` &
45 execute_commands
"${COMMANDS_AC_UNPLUGGED[@]}"
48 00000001) # AC plugged-in
49 # These events are generated twice (at least on the 1000)
50 # Make sure the commands are executed only once
51 if [ ! -e ${EEEPC_VAR}/ac_event_plugged
]; then
52 touch ${EEEPC_VAR}/ac_event_plugged
53 # Wait 5 seconds (in background) before deleting the file
54 echo `sleep 5 && rm -f ${EEEPC_VAR}/ac_event_plugged` &
55 execute_commands
"${COMMANDS_AC_PLUGGED[@]}"
59 msg
="acpi-eeepc-generic-handler: undefined 'ac_adapter' event: $2 $3 $4"
68 eeepc_notify
"Power button pressed" gnome-session-halt
69 execute_commands
"${COMMANDS_POWER_BUTTON[@]}"
72 msg
="acpi-eeepc-generic-handler: undefined 'button/power' event: $2 $3 $4"
73 eeepc_notify
"$msg" keyboard
81 suspend_check_blacklisted_processes
"${SUSPEND_BLACKLISTED_PROCESSES[@]}"
82 if [ -e "${EEEPC_VAR}/power.lock" ]; then
83 msg
="Suspend lock exist, canceling suspend"
84 logger
"$msg (${EEEPC_VAR}/power.lock)"
85 eeepc_notify
"$msg" stop
5000
88 eeepc_notify
"Sleep button pressed" gnome-session-suspend
89 execute_commands
"${COMMANDS_SLEEP[@]}"
92 msg
="acpi-eeepc-generic-handler: undefined 'button/sleep' event: $2 $3 $4"
93 eeepc_notify
"$msg" keyboard
99 # Detect correctly lid state
101 # /proc/acpi is deprecated
102 [ -e /proc
/acpi
/button
/lid
/LID
/state
] && \
103 lidstate
=$
(cat /proc
/acpi
/button
/lid
/LID
/state |
awk '{print $2}')
104 [ "x$lidstate" == "x" ] && \
105 [ "x$3" != "x" ] && lidstate
=$3 # Use event given (2rd argument) to acpid
106 # FIXME: It seems there is no /sys inteface to replace this
107 # old /proc/acpi interface, so the latter is not deprecated...
111 xset dpms force on
# Screen on
112 restore_brightness
# Restore brightness
115 save_brightness
# Save brightness
116 if [ "$COMMANDS_ON_LID_CLOSE" == "yes" ]; then
117 state_file1
="/proc/acpi/ac_adapter/AC0/state"
118 state_file2
="/sys/class/power_supply/AC0/online"
119 # /proc/acpi/* is deprecated
120 [ -e $state_file1 ] && ac_state
=$
(cat $state_file1 |
awk '{print $2}' )
122 [ -e $state_file2 ] && ac_state
=$
(cat $state_file2)
126 # AC adapter plugged in
127 execute_commands
"${COMMANDS_LID_CLOSE_ON_AC[@]}"
131 execute_commands
"${COMMANDS_LID_CLOSE_ON_BATTERY[@]}"
137 msg
="acpi-eeepc-generic-handler: undefined 'button/lid' event: $2 $3 $4"
138 eeepc_notify
"$msg" keyboard
144 $EEEPC_BLANK) # Silver function button 1 (Blank)
145 logger
"acpi-eeepc-generic-handler: (hotkey): Silver function button (Blank)"
146 execute_commands
"${COMMANDS_BUTTON_BLANK[@]}"
148 $EEEPC_RESOLUTION) # Silver function button 2 (Resolution)
149 logger
"acpi-eeepc-generic-handler: (hotkey): Silver function button (Resolution)"
150 execute_commands
"${COMMANDS_BUTTON_RESOLUTION[@]}"
152 $EEEPC_USER1) # Silver function button 3 (User1)
153 logger
"acpi-eeepc-generic-handler: (hotkey): Silver function button (User1)"
154 execute_commands
"${COMMANDS_BUTTON_USER1[@]}"
156 $EEEPC_USER2) # Silver function button 4 (User2)
157 logger
"acpi-eeepc-generic-handler: (hotkey): Silver function button (User2)"
158 execute_commands
"${COMMANDS_BUTTON_USER2[@]}"
160 $EEEPC_SHE_TOGGLE) # Super Hybrid Engine
161 logger
"acpi-eeepc-generic-handler: (hotkey): SHE"
162 execute_commands
"${COMMANDS_SHE_TOGGLE[@]}"
166 suspend_check_blacklisted_processes
"${SUSPEND_BLACKLISTED_PROCESSES[@]}"
167 logger
"acpi-eeepc-generic-handler: (hotkey): Sleep"
168 eeepc_notify
"Going to sleep..." gnome-session-suspend
169 execute_commands
"${COMMANDS_SLEEP[@]}"
171 $EEEPC_WIFI_TOGGLE) # WiFi Toggle
172 logger
"acpi-eeepc-generic-handler: (hotkey): WiFi toggle"
173 execute_commands
"${COMMANDS_WIFI_TOGGLE[@]}"
175 $EEEPC_WIFI_UP) # WiFi Up
176 logger
"acpi-eeepc-generic-handler: (hotkey): WiFi Up"
177 execute_commands
"${COMMANDS_WIFI_UP[@]}"
179 $EEEPC_WIFI_DOWN) # WiFi Down
180 logger
"acpi-eeepc-generic-handler: (hotkey): WiFi Down"
181 execute_commands
"${COMMANDS_WIFI_DOWN[@]}"
183 $EEEPC_TOUCHPAD_TOGGLE) # Toggle touchpad
184 logger
"acpi-eeepc-generic-handler: (hotkey): Toggling touchpad"
185 execute_commands
"${COMMANDS_TOUCHPAD_TOGGLE[@]}"
187 $EEEPC_RESOLUTION) # Change resolution
188 logger
"acpi-eeepc-generic-handler: (hotkey): Changing resolution"
189 execute_commands
"${COMMANDS_RESOLUTION[@]}"
191 $EEEPC_ROTATE) # Rotate screen.
192 logger
"acpi-eeepc-generic-handler: (hotkey): Rotate"
193 execute_commands
"${COMMANDS_ROTATE_TOGGLE[@]}"
195 $EEEPC_BRIGHTNESS_UP|
$EEEPC_BRIGHTNESS_DOWN) # Brightness
196 brightness_direction
=`brightness_find_direction`
197 if [ "$brightness_direction" == "up" ]; then
198 execute_commands
"${COMMANDS_BRIGHTNESS_UP[@]}"
199 brightness_percentage
=`brightness_get_percentage`
200 [ "$brightness_percentage" != "100" ] && logger
"acpi-eeepc-generic-handler: (hotkey): Brightness Up ($brightness_percentage%)"
201 #[ "$brightness_percentage" != "100" ] && eeepc_notify "Brightness Up ($brightness_percentage%)" dialog-information
202 elif [ "$brightness_direction" == "down" ]; then
203 execute_commands
"${COMMANDS_BRIGHTNESS_DOWN[@]}"
204 brightness_percentage
=`brightness_get_percentage`
205 [ "$brightness_percentage" != "0" ] && logger
"acpi-eeepc-generic-handler: (hotkey): Brightness Down ($brightness_percentage%)"
206 #[ "$brightness_percentage" != "0" ] && eeepc_notify "Brightness Down ($brightness_percentage%)" dialog-information
209 $EEEPC_SCREEN_OFF) # Turn off screen
210 execute_commands
"${COMMANDS_SCREEN_OFF[@]}"
211 eeepc_notify
"Turning screen off..." dialog-information
213 $EEEPC_XRANDR_TOGGLE) # RandR
214 execute_commands
"${COMMANDS_XRANDR_TOGGLE[@]}"
215 eeepc_notify
"Toggling displays..." video-display
217 $EEEPC_XRANDR_TOGGLE_0) # RandR
218 execute_commands
"${COMMANDS_XRANDR_TOGGLE[@]}"
219 eeepc_notify
"Toggling displays..." video-display
221 $EEEPC_XRANDR_TOGGLE_1) # RandR
222 execute_commands
"${COMMANDS_XRANDR_TOGGLE[@]}"
223 eeepc_notify
"Toggling displays..." video-display
225 $EEEPC_XRANDR_TOGGLE_2) # RandR
226 execute_commands
"${COMMANDS_XRANDR_TOGGLE[@]}"
227 eeepc_notify
"Toggling displays..." video-display
229 $EEEPC_TASKMAN) # Task Manager
230 logger
"acpi-eeepc-generic-handler: (hotkey): Task Manager"
231 execute_commands
"${COMMANDS_TASKM[@]}"
233 $EEEPC_VOL_MUTE) # Mute
234 logger
"acpi-eeepc-generic-handler: (hotkey): Mute"
235 execute_commands
"${COMMANDS_MUTE[@]}"
236 if [ "`volume_is_mute`" == "1" ]; then
237 volume_icon
="audio-volume-muted"
239 elif [ "`volume_is_mute`" == "0" ]; then
240 volume_icon
="audio-volume-medium"
243 eeepc_notify
"${mute_toggle}Mute (`get_volume`%)" $volume_icon
245 $EEEPC_VOL_DOWN) # Volume Down
246 if [ "`volume_is_mute`" == "1" ]; then
247 volume_icon
="audio-volume-muted"
248 elif [ "`volume_is_mute`" == "0" ]; then
249 volume_icon
="audio-volume-low"
251 if [ "`get_volume`" != "0" ]; then
252 execute_commands
"${COMMANDS_VOLUME_DOWN[@]}"
253 eeepc_notify
"Volume Down (`get_volume`%)" $volume_icon
256 $EEEPC_VOL_UP) # Volume Up
257 if [ "`volume_is_mute`" == "1" ]; then
258 volume_icon
="audio-volume-muted"
259 elif [ "`volume_is_mute`" == "0" ]; then
260 volume_icon
="audio-volume-high"
262 if [ "`get_volume`" != "100" ]; then
263 execute_commands
"${COMMANDS_VOLUME_UP[@]}"
264 eeepc_notify
"Volume Up (`get_volume`%)" $volume_icon
267 00000050|
00000051) # AC is plugged-in or unplugged
268 # Don't do anything, should be handled in ac_adapter group
270 # 00000052) # battery level critical
271 # logger "Battery is critical, suspending"
272 # $BATTERY_CRITICAL &
275 msg
="Hotkey (hotkey) undefined: $2 $3 $4"
276 eeepc_notify
"$msg" keyboard
281 msg
="acpi-eeepc-generic-handler: undefined group/action ($1) event: $2 $3 $4"
282 eeepc_notify
"$msg" keyboard