updated on Tue Jan 17 12:00:36 UTC 2012
[aur-mirror.git] / acpi-eeepc-generic-svn / acpi-eeepc-generic-suspend2ram.sh
blobb89e6b49e67340ef4f43f05eb4f3fd340c917965
1 #!/bin/sh
3 source /etc/conf.d/acpi-eeepc-generic.conf
4 source /etc/acpi/eeepc/acpi-eeepc-generic-functions.sh
6 function suspend_check_blacklisted_processes() {
7 processes=( "$@" )
8 p_num=${#processes[@]}
9 logger "Checking for processes before suspending: $processes ($p_num)"
10 for ((i=0;i<${p_num};i++)); do
11 p=${processes[${i}]}
12 pid=`pidof $p`
13 logger "process #$i: $p ($pid)"
14 echo "process #$i: $p ($pid)"
15 [ "x$pid" != "x" ] &&
16 echo "$p is running! Canceling suspend" &&
17 logger "$p is running! Canceling suspend" &&
18 exit 0
19 done
22 suspend_check_blacklisted_processes "${SUSPEND_BLACKLISTED_PROCESSES[@]}"
24 if [ -e "${EEEPC_VAR}/power.lock" ]; then
25 logger "${EEEPC_VAR}/power.lock exist, canceling suspend"
26 exit 0
29 vga_is_on=`xrandr | grep -A 1 VGA | grep "*"`
30 if [ "x$vga_is_on" != "x" ]; then
31 logger "VGA is up and running, canceling suspend"
32 exit 0
35 if grep -q mem /sys/power/state ; then
37 # BEGIN SUSPEND SEQUENCE
39 logger "Start suspend sequence"
41 # get console number
42 CONSOLE_NUMBER=$(fgconsole)
43 logger "Saving console number: $CONSOLE_NUMBER"
45 # save the brightness value
46 BRN=`cat /sys/class/backlight/eeepc/actual_brightness`
47 logger "Saving brightness value: $BRN"
49 # save the FSB value and go to powersaver mode
50 # /etc/acpi/eee/fsb.sh autosuspend
51 logger "Save the FSB value and go to powersaver mode: DISABLE"
54 LOADEEE="no"
55 EEESTATE=$(lsmod | grep eee | awk {'print $1'})
56 if [ "X$EEESTATE" == "Xeee" ];
57 then
58 modprobe -r eee
59 LOADEEE="yes"
60 logger "Unloading eee module";
63 # flush the buffers to disk
64 sync
66 # change virtual terminal to not screw up X
67 chvt 1
69 # put us into suspend state
70 echo -n "mem" > /sys/power/state
72 logger "BEGIN WAKEUP SEQUENCE..."
74 #Ugly but effective way to restore screen
75 #/usr/sbin/vbetool post
76 chvt $CONSOLE_NUMBER
78 # restore backlight BRN
79 sleep 1
80 echo $BRN > /sys/class/backlight/eeepc/brightness
81 logger "Restoring brightness"
83 # # restore the FSB value
84 # /etc/acpi/eee/fsb.sh autoresume
88 exit 0