Skip to content

Instantly share code, notes, and snippets.

@Lvl4Sword
Created October 13, 2018 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lvl4Sword/ed695203a4355c2096d44d70ae028e36 to your computer and use it in GitHub Desktop.
Save Lvl4Sword/ed695203a4355c2096d44d70ae028e36 to your computer and use it in GitHub Desktop.
Detect idle time, because why not
import subprocess
import time
while True:
time.sleep(1)
a = subprocess.check_output('xprintidle')
a = round(int(a.decode().strip()), -3)
print('Seconds idle: {0}'.format(int(a / 1000)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment