Reputation: 374
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
Reputation:
You cannot unsuspend a computer by running any script if it's suspended as it will not execute any script.
Upvotes: 0
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