1 """
2 count down the time to close the display
3 Create by Zhong Xiewei
4 """
5 import time
6 import os
7 import platform
8
9 work_time = int(raw_input("Enter your work time [min]: "))
10 break_time = int(raw_input("Enter your break time [min]: "))
11 break_time = break_time*60
12 start = raw_input("Do you want start [y/n]: ")
13 os_str = platform.system()
14
15 work_stage = 0
16 while (start == 'y'):
17 for i in range(work_time):
18 print 'Remain ', work_time-i, 'min'
19 time.sleep(60)
20
21 # During the break time
22 # the display should always be closed
23 # if rewake by mouse, it will be closed again
24 insleep = 1
25 start_time = time.time()
26 while (insleep):
27 if os_str == "Windows":
28 # Under windows, nircmd should be installed first
29 # The usage can reference: www.nirsoft.net/utils/nircmd.html
30 os.system("nircmd.exe monitor off")
31 elif os_str == "Linux":
32 os.system("xset dpms force off")
33 end_time = time.time()
34 if end_time-start_time > break_time:
35 insleep = 0
36
37 if os_str == "Linux":
38 os.system("xset dpms force on")
39 elif os_str == "Windows":
40 os.system("nircmd.exe monitor on")
41
42 work_stage = work_stage + 1
43 print "================\nWork Stage ", work_stage,"\n================\n"
44 start = raw_input("Do you want continue [y/n]: ")