4

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?

MattK
  • 41

2 Answers2

0

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.

Bazz
  • 1
0

Here's what worked for me when plugging my closed laptop into my Lenovo DisplayLink hub:

  1. Used # udevadm monitor to identify the correct usb port when I connect my hub. (For me it was usb3.)

  2. sudo sh -c 'echo enabled > /sys/bus/usb/devices/[DEVICE]/power/wakeup'

My actual command was:

sudo sh -c 'echo enabled > /sys/bus/usb/devices/usb3/power/wakeup'

Kudos to these helpful articles: