Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import with_statement
- from Xlib.display import Display
- import time
- def get_focus():
- focus = Display().get_input_focus()
- return (focus.focus.get_wm_name(), focus.focus.get_wm_class())
- def main():
- (wm_name, wm_class) = get_focus()
- with open("test.log", 'a+') as fileHandle:
- fileHandle.write("%s %s %s\n" % (time.asctime(), wm_name, wm_class, ))
- while (1):
- if (wm_name, wm_class) != get_focus():
- wm_name, wm_class = get_focus()
- fileHandle.write("%s %s %s\n" % (time.asctime(), wm_name, wm_class, ))
- time.sleep(3)
- if __name__ == "__main__":
- main()
Add Comment
Please, Sign In to add comment