title: How to prevent a script being stopped by suspend?
body: <p>I have a python alarm clock script, which needs to wake me up at some time.When I go to bed and leave it running, the laptop I use which has Linux Mint suspends itself after some time of inactivity.How can I prevent my script from being stopped and keep it running? My laptop is in my room and I need to close its lid because its light is annoying to sleep to.Here is my script.</p>
  
  <pre><code>import time
  import sys
  import webbrowser
  
  alarm_HH = raw_input("Enter the hour you want to wake up at\n")
  alarm_MM = raw_input("Enter the minute you want to wake up at\n")
  
  print("You want to wake up at ", alarm_HH)
  while True:
      now = time.localtime()
      if now.tm_hour == int(alarm_HH) and now.tm_min == int(alarm_MM):
          webbrowser.open_new_tab("http://www.repeatmyvids.com/watch?v=SXLplRtMNfg&amp;kmdom=youtube")
          break
  
      else:
          timeout = 60 - now.tm_sec
          if raw_input("Want me to stop?"):
            break 
  </code></pre>
  
  <p>[EDIT]</p>
  
  <p>Ok so I figured it out.I installed python xlib module, which is a low level python library that you can install with <code>sudo aptitude install python-xlib</code>.I added a few lines of code that move the mouse pointer in order to prevent suspend, or sleep, so that my script can still work with lid closed and no input from anywhere.</p>
  
  <pre><code>    d = display.Display()
      s = d.screen()
      root = s.root
      root.warp_pointer(500,500)
      d.sync()
  </code></pre>
  
  <p>I added a few of these, and the code now looks like this.</p>
  
  <pre><code>import time
  import sys
  import webbrowser
  from Xlib import X, display
  
  alarm_HH = input("Enter the hour you want to wake up at\n")
  alarm_MM = input("Enter the minute you want to wake up at\n")
  
  print("You want to wake up at ", alarm_HH)
  while True:
      now = time.localtime()
      if now.tm_hour == int(alarm_HH) and now.tm_min == int(alarm_MM):
          webbrowser.open_new_tab("http://www.repeatmyvids.com/watch?v=SXLplRtMNfg&amp;kmdom=youtube")
          break
  
      else:
          d = display.Display()
          s = d.screen()
          root = s.root
          root.warp_pointer(500,500)
          d.sync()
  
          time.sleep( 5 )
          root.warp_pointer(250,250)
          d.sync()
  
          time.sleep( 5 )
          root.warp_pointer(100,100)
          d.sync()
  
          time.sleep( 5 )
          root.warp_pointer(250,250)
          d.sync()
  </code></pre>
  
  <p>Thanks to EngHamoud for giving me the idea to move the pointer in order to prevent suspend.</p>