How to modify the lid-close behavoir?

2,069 views
Skip to first unread message

Geoffrey Plitt

unread,
Dec 15, 2014, 9:56:10 PM12/15/14
to chromium-...@chromium.org
Hi,

I have a Dell Chromebook 9, and I'd like to modify the lid-closing behavior. I've asked in other forums and there doesn't seem to be a way to do this with normal everyday user settings, so my question is: once I enable dev mode and "unlock" the chromebook, how do I modify the lid-close behavior to shutdown instead of sleep? I'm a software engineer, so I should be able to do it if I know where to look. How do I find where these events are hooked up?

Background: For a lot of people out there, the opposite problem existed: Their chromebooks shut down on lid-close when they didn't want that, so there are tons of articles about how to change this so that the chromebook sleeps instead of shutting down. My problem is the opposite-- I close the lid, forgetting to shutdown all the way, and then come back to a dead battery (uses way more battery when sleeping than when off completely). I asked in other forums and eventually reached a dead end, there's no normal way to modify this behavior.

Interested to fork the codebase and modify the behavior if someone can give me some pointers on what code to modify, thanks.

-G

Bartosz Fabianowski

unread,
Dec 16, 2014, 4:15:03 AM12/16/14
to ge...@gweb.org, chromium-...@chromium.org
Try adding the following to /home/chronos/Local State (the file must be
valid JSON, so make sure to add a comma at the end of the preceding
section):

"power": {
"lid_closed_action": 2
}

For a list of valid values other than 2, see the LidCloseAction policy here:

https://chromium.googlesource.com/chromium/src/+/master/components/policy/resources/policy_templates.json

For a list of available power management settings, see the
PowerPrefs::UpdatePowerPolicyFromPrefs() method here:

https://chromium.googlesource.com/chromium/src/+/master/chrome/browser/chromeos/power/power_prefs.cc

- Bartosz

Geoff Plitt

unread,
Dec 18, 2014, 1:41:37 AM12/18/14
to Bartosz Fabianowski, chromium-...@chromium.org
Thanks, I tried that, but the file got overwritten while I had the text editor. Tried again, and it held, but the file was overwritten a few seconds later. I'm not familiar enough with ChromeOS to know if it's normal to expect a race condition of some background daemon restoring the file as I try to save it-- is it normal?

Bartosz Fabianowski

unread,
Dec 18, 2014, 8:48:10 AM12/18/14
to Geoff Plitt, chromium-...@chromium.org
What you are racing against here is Chrome itself. Simply run "stop ui"
before editing the file "start ui" afterward.

- Bartosz

Geoff Plitt

unread,
Dec 18, 2014, 3:02:54 PM12/18/14
to Bartosz Fabianowski, chromium-...@chromium.org
Thanks!

I successfully updated the json entry in that file. I can tell because when I reboot and examine the file, it's moved the key to a different spot, but it's there, so the JSON syntax is correct (and I've checked the spelling).

But when I close the lid, wait a minute, and open it again, I'm right at the login screen, the "shutdown" action (2) did not happen.

Are there some logs I can check or something to delve further?

Bartosz Fabianowski

unread,
Dec 19, 2014, 4:24:40 AM12/19/14
to Geoff Plitt, chromium-...@chromium.org
My bad. I told you to put this setting in Local State, which only
affects power management on the login screen. You will need to put it
into your user's Preferences file. Here is the flow for this:

- Log in
- Switch to a terminal:
stop ui
cd /home/user/your_username_hash
edit the Preferences file
start ui

This should change the preferences for your user.

- Bartosz

Geoff Plitt

unread,
Dec 20, 2014, 3:32:34 PM12/20/14
to Bartosz Fabianowski, chromium-...@chromium.org
Once I stop the ui and go to /home/user/[hash], there is no preferences files, that folder has no contents.

Richard Barnette

unread,
Dec 22, 2014, 1:33:51 PM12/22/14
to ge...@gweb.org, Bartosz Fabianowski, chromium-...@chromium.org
On 12/20/14, 12:32 PM, Geoff Plitt wrote:
> Once I stop the ui and go to /home/user/[hash], there is no preferences
> files, that folder has no contents.
>
Ah. Alas, that's expected. That directory will only be
mounted when Chrome is running and the user is actually
logged in to the browser. The underlying data is stored
encrypted, so getting to it any other way is likely somewhere
between "impossible" and "not worth the trouble".

I assume the original suggestion to stop Chrome before
editing the content was to prevent conflicts with Chrome's
own use of the file. It's likely that there's a way around
that challenge short of stopping Chrome. Someone with Chrome
experience will need to comment.


> On Fri, Dec 19, 2014 at 1:24 AM, Bartosz Fabianowski
> <bar...@chromium.org <mailto:bar...@chromium.org>> wrote:
>
> My bad. I told you to put this setting in Local State, which only
> affects power management on the login screen. You will need to put
> it into your user's Preferences file. Here is the flow for this:
>
> - Log in
> - Switch to a terminal:
> stop ui
> cd /home/user/your_username_hash
> edit the Preferences file
> start ui
>
> This should change the preferences for your user.
>
> - Bartosz
>
>

--jrb

Geoff Plitt

unread,
Jan 4, 2015, 9:26:32 PM1/4/15
to Richard Barnette, Bartosz Fabianowski, chromium-...@chromium.org
Thanks! Does anyone else have suggestions for how to stop Chrome as suggested above, and safely+permanently edit the /home/user/your_username_hash/Preferences file?

Bartosz Fabianowski

unread,
Jan 7, 2015, 8:41:09 AM1/7/15
to Geoff Plitt, Richard Barnette, chromium-...@chromium.org
Did you log in before stopping Chrome? Stopping Chrome should not
unmount your encrypted home directory. It should still be there. I
actually verified that the steps work for me before sending them to you.

If for some reason the directory really is not mounted after stopping
Chrome, even though you had logged in, you can always easily mount it
yourself from the command line:

cryptohome --action=mount --user=yo...@email.address

- Brtosz
Reply all
Reply to author
Forward
0 new messages