Advertisement
rezasurmar

Untitled

Oct 11th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. #!/usr/bin/env python
  2. from datetime import datetime
  3. import os
  4. import pwd
  5. import subprocess
  6. import time
  7.  
  8. LOG_FILE = os.path.expanduser('~/hours_log.csv')
  9.  
  10.  
  11. cmd = subprocess.Popen(["dbus-monitor \"type='signal',interface="
  12.                             "'org.freedesktop.ScreenSaver'\""], shell=True,
  13.                                                    stdout=subprocess.PIPE)
  14.  
  15. running = 0
  16. while 1:
  17.         time.sleep(0.1)
  18.         if running:
  19.             output = cmd.stdout.readline()
  20.             status = 'unlocked' if 'true' in output else 'locked'
  21.  
  22.             if status == 'unlocked'
  23.                 Os.system("./LCDsaver.sh 1")
  24.             else
  25.                 Os.system("./LCDsaver.sh 0")
  26.  
  27.             running = 0
  28.          line = cmd.stdout.readline()
  29.          if "ActiveChange" in line and 'org.freedesktop.ScreenSaver' in line:
  30.               running = 1
  31. ~
  32. ~
  33. ~
  34. ~
  35. ~
  36. ~
  37. ~
  38.                                                                                         30,25    Wszystko
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement