bamia
bamia

Reputation: 374

How to "unsuspend" a computer using command line

I'm writing a script to define what happens when I dock/undock the computer. I want it to suspend when I undock the computer while the lid is closed and "unsuspend" when I dock it back. Is there any way I could do this in a bash script?

Upvotes: 0

Views: 1193

Answers (2)

user12770350
user12770350

Reputation:

You cannot unsuspend a computer by running any script if it's suspended as it will not execute any script.

Upvotes: 0

Xypron
Xypron

Reputation: 2483

If a computer is suspended, it cannot run any script. So waking up via bash is impossible.

systemctl suspend is the console command to suspend your computer.

Dock and undock scripts can be triggered via udev, cf. https://help.ubuntu.com/community/LaptopLidAndDockScripts#Dock_and_Undock_Scripts.

Using lid open and close events is described here: https://askubuntu.com/questions/525995/catch-lid-close-and-open-events

Upvotes: 3

Related Questions