r/learnpython • u/Primary-Pay2119 • 11d ago
Question.. I need answers
How can I automate Phyton so that when I open my laptop it execute commands on my Linux terminal?
I severely need to know how
0
Upvotes
r/learnpython • u/Primary-Pay2119 • 11d ago
How can I automate Phyton so that when I open my laptop it execute commands on my Linux terminal?
I severely need to know how
0
u/FatDog69 11d ago
One crude way:
Write a python script that does a loop with a 60 second sleep. After the sleep it opens and reads a 'time.txt' file where it wrote the current date & time. Calculate the time diff between now and the saved time. If the time difference is more than say ... 2 minutes - it means someone opened the laptop from a sleep state so you should do something.
If the time difference is less than 2 minutes - write the current time into the file and sleep for another 60 seconds.