Advertisement
rezasurmar

Untitled

Oct 11th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 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.             if status == 'unlocked':
  22.                 os.system("LCDsaver.sh 1")
  23.             else
  24.                 os.system("LCDsaver.sh 0")
  25.  
  26.             running = 0
  27.  
  28.         line = cmd.stdout.readline()
  29.  
  30.         if "ActiveChange" in line and 'org.freedesktop.ScreenSaver' in line:
  31.             running = 1
  32. ~
  33. ~
  34. ~
  35. ~
  36. ~
  37. ~
  38. -- WIZUALNY --                                      31        1,1      Wszystko
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement