Reputation: 43
using python coding i want to make make the system to get sleep state , is that possible ? i need the solution in Ubuntu , i can find that for windows but for Ubuntu is their any solution ?
Upvotes: 0
Views: 406
Reputation: 1694
Using os.system you can call terminal commands.
You can for instance use systemctl hibernate
to get Ubuntu to sleep.
import os
os.system("systemctl hibernate")
Note: you might need to run your python file using sudo
.
Upvotes: 1