最近发现自己花在刷手机的时间上比较多,特别是晚上睡觉前,总是忍不住再刷个把小时,简直浪费生命
用了一加手机的禅定模式后,这种现象终于有所改善。果然改变习惯从改变环境开始。。。。
但是有时候虽然没有玩手机,却用电脑玩游戏,看电影到深夜。怎么办呢? 灵机一动自己做一个电脑班的禅定模式不就行了吗哈哈
我的想法是 python的命令配合window的计划任务,就可以做一个在指定的时间内自动休眠电脑的routine
以下是python的程序
# make a task in taskschd.msc so the script will be run with trggering
import time, datetime
import subprocess
today = datetime.datetime.fromtimestamp(time.time()) ## get time
hour = int(today.strftime("%H")) ##get hour
if (hour>=0) and (hour<=4): #0-5 am PC will hiberate automatically
#Hibernate
subprocess.Popen("rundll32 powrprof.dll,SetSuspendState Hibernate")
然后在运行里输入taskschd.msc打开计划任务,点击创建任务