| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 | 2 |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # Shutdown instead of sleeping if no one is logged in | 7 # Shutdowns instead of sleeping if no one is logged in. |
| 8 if ! test -f /var/run/state/logged-in; then | 8 if ! test -f /var/run/state/logged-in; then |
| 9 shutdown -h now | 9 shutdown -h now |
| 10 exit 0 | 10 exit 0 |
| 11 fi | 11 fi |
| 12 | 12 |
| 13 # Check whether the lid is closed before proceeding | 13 # Checks whether the lid is closed before proceeding. |
| 14 grep -q open /proc/acpi/button/lid/*/state | 14 grep -q open /proc/acpi/button/lid/*/state |
| 15 if [ $? = 0 ]; then | 15 if [ $? = 0 ]; then |
| 16 exit 0 | 16 exit 0 |
| 17 fi | 17 fi |
| 18 | 18 |
| 19 # On lid close: | 19 # On lid close: |
| 20 # - lock the screen | 20 # - locks the screen |
| 21 export HOME=/home/chronos | 21 export HOME=/home/chronos |
| 22 /usr/bin/xscreensaver-command -l | 22 /usr/bin/xscreensaver-command -l |
| 23 | 23 |
| 24 # - sleep for a bit to give the window manager time to draw the xscreensaver | 24 # - announces the event |
| 25 /usr/bin/dbus-send --type=signal --system / \ |
| 26 org.chromium.Power.Manager.PowerStateChanged string:mem |
| 27 |
| 28 # - sleeps for a bit to give the window manager time to draw the xscreensaver |
| 25 # window to the screen -- see http://crosbug.com/2250. | 29 # window to the screen -- see http://crosbug.com/2250. |
| 26 # TODO: Remove this hack once we have a better solution in place that adds | 30 # TODO: Remove this hack once we have a better solution in place that adds |
| 27 # some coordination between the screen locker and the window manager. | 31 # some coordination between the screen locker and the window manager. |
| 28 sleep 0.5 | 32 sleep 0.5 |
| 29 | 33 |
| 30 # - suspend the cryptohome device | 34 # - suspends the cryptohome device |
| 31 #CRYPTOHOME=/dev/mapper/cryptohome | 35 #CRYPTOHOME=/dev/mapper/cryptohome |
| 32 #/usr/bin/test -b $CRYPTOHOME && /sbin/dmsetup suspend $CRYPTOHOME | 36 #/usr/bin/test -b $CRYPTOHOME && /sbin/dmsetup suspend $CRYPTOHOME |
| 33 | 37 |
| 34 # - suspend to ram | 38 # - suspends to ram |
| 35 echo -n mem > /sys/power/state | 39 echo -n mem > /sys/power/state |
| 36 | 40 |
| 37 # On lid open: | 41 # On lid open: |
| 38 # - has it such that you don't have to press a key to display lock screen | 42 # - has it such that you don't have to press a key to display lock screen |
| 39 /usr/bin/xscreensaver-command -deactivate | 43 /usr/bin/xscreensaver-command -deactivate |
| 40 | 44 |
| 41 # - resume cryptohome device | 45 # - announces the event |
| 46 /usr/bin/dbus-send --type=signal --system / \ |
| 47 org.chromium.Power.Manager.PowerStateChanged string:on |
| 48 |
| 49 # - resumes cryptohome device |
| 42 #/usr/bin/test -b $CRYPTOHOME && /sbin/dmsetup resume $CRYPTOHOME | 50 #/usr/bin/test -b $CRYPTOHOME && /sbin/dmsetup resume $CRYPTOHOME |
| OLD | NEW |