Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1620)

Side by Side Diff: action_lid.sh

Issue 2626006: Update action_lid.sh to use new RequestSuspend signal (6 of 7). (Closed) Base URL: ssh://git@chromiumos-git/acpi.git
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 logger "action_lid.sh: " `cat /proc/acpi/button/lid/*/state` 7 logger "action_lid.sh: " `cat /proc/acpi/button/lid/*/state`
8 8
9 grep -q "closed" /proc/acpi/button/lid/*/state 9 grep -q "closed" /proc/acpi/button/lid/*/state
10 if [ $? != 0 ]; then 10 if [ $? != 0 ]; then
11 logger "action_lid.sh: lid is not closed. Bailing out." 11 logger "action_lid.sh: lid is not closed. Bailing out."
12 exit 0 12 exit 0
13 fi 13 fi
14 14
15 15 logger "action_lid.sh: lid closed. Requesting suspend."
Sameer Nanda 2010/06/07 02:38:34 use '-t' to add a tag and preferably use the same
16 # Shutdowns instead of sleeping if no one is logged in.
17 if ! test -f /var/run/state/logged-in; then
18 logger "action_lid.sh: lid closed. Shutting down since no one is logged in"
19 shutdown -h now
20 exit 0
21 fi
22
23 logger "action_lid.sh: lid closed. Going to suspend-to-RAM state"
24
25 # On lid close:
26 # - locks the screen
27 export HOME=/home/chronos
28 /usr/bin/xscreensaver-command -l
29
30 # - logs the time going to suspend (no-op if no RTC).
31 cp /sys/class/rtc/rtc0/since_epoch /var/log/metrics/suspend-to-ram-time \
32 2> /dev/null || true
33
34 # - announces the event
35 /usr/bin/dbus-send --type=signal --system / \ 16 /usr/bin/dbus-send --type=signal --system / \
36 org.chromium.Power.Manager.PowerStateChanged string:mem 17 org.chromium.PowerManager.RequestSuspend
37
38 # - sleeps for a bit to give the window manager time to draw the xscreensaver
39 # window to the screen -- see http://crosbug.com/2250.
40 # TODO: Remove this hack once we have a better solution in place that adds
41 # some coordination between the screen locker and the window manager.
42 sleep 0.5
43
44 # - suspends the cryptohome device
45 #CRYPTOHOME=/dev/mapper/cryptohome
46 #/usr/bin/test -b $CRYPTOHOME && /sbin/dmsetup suspend $CRYPTOHOME
47
48 # - suspends to ram
49 echo -n mem > /sys/power/state
50
51 # On lid open:
52 # - has it such that you don't have to press a key to display lock screen
53 /usr/bin/xscreensaver-command -deactivate
54
55 # - announces the event
56 /usr/bin/dbus-send --type=signal --system / \
57 org.chromium.Power.Manager.PowerStateChanged string:on &
58
59 # - sends UMA metrics on resume
60 /usr/bin/send_metrics_on_resume
61
62 # - resumes cryptohome device
63 #/usr/bin/test -b $CRYPTOHOME && /sbin/dmsetup resume $CRYPTOHOME
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698