Score:2

configure laptop to unsuspend when connected to external power

ca flag

I have a frame.work ubuntu 21.10 laptop that I connect often to a usb-c hub that has a monitor, keyboard and mouse.

I currently pull my laptop out and plug in the usb-c hub but then open the laptop lid to un suspend, then close the lid to make my main monitor the only display.

I'd like to put the laptop in a holder that would make it difficult to connect to power and open the lid.

When the laptop lid is closed and on battery power, I'd like the laptop to suspend. When the laptop lid is closed and connected to ac power, I'd like the laptop to wake so that I can use it as soon as possible. When the laptop lid is closed and I disconnect ac power, I'd like the laptop to suspend after a few minutes.

If the laptop is connected to AC power, I'd like the power profile set to maximum. If the laptop is on battery, I'd like the power profile set to energy saver.

Is there any app or setting that does this? If not, how do I catch these events and set a service to manage these states?

WinEunuuchs2Unix avatar
in flag
There are a lot of points here. Another point to add is when laptop is plugged into docking station, you shouldn't have to lift the lid to wake it up. You should only have to jiggle the mouse or touch a single key like the first letter of your user id to wake up the system. The other issues you raised though can be addressed with `udev` (**user space `/dev`**) rules.
Score:0
kr flag

Don't you need to log in when your device is suspended? In that case the monitor would need to bypass the authentication process, and my guess is that by default, the system does not automatically read devices connected to the periphery in order to avoid vulnerabilities. ( cf article: "Numerous attacks have been demonstrated by vulnerable or malicious USB peripherals. USB attacks work by altering the firmware of USB devices so they register as deceptive device types when plugged into a machine. For example, a USB mass storage device could masquerade as a keyboard to gain the ability to inject malicious keystrokes." ).

Assuming working around this obstacle is possible, you would still have to deal with the resulting vulnerability. I don't think there exists an app for this feature unless the hardware provider offers a driver for that purpose or you write one yourself (can't tell you how you would do that though)

On the other hand, what you can do is disable the lock-on-suspend configuration. I use my Ubuntu 20.04 desktop with a projector permanently connected to it, and I wake it up with a wireless bluetooth keyboard without opening the lid. Read this for infos on how to change lock screen behaviour or this on how to change lid closing behaviour. Nevertheless, keyboard input is still required to wake the screen up.

David avatar
cn flag
There is no version of Ubuntu called Ubuntu 20
MattK avatar
ca flag
Thanks Bazz! I do not want to unlock my computer, that's a good point to clarify. When I open my laptop lid I get the authentication prompt. I would like to see that prompt when I plug in AC power - I don't need it to suspend when AC power has been plugged in. I'd like it to unsuspend and present the login prompt - at which point I can use my USB peripherals to type in the password, just like when I open the laptop lid while it is connected to the hub. I have read the logind.conf docs and I don't think they allow me to unsuspend on ac power being connected - happy to know if that's wrong.
WinEunuuchs2Unix avatar
in flag
@Bazz when you live alone there is no need to have computer prompt for password when resuming from suspend or waking up from sleep. A simple password prompt when running `sudo` or rebooting once every few months should suffice.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.