Created
February 18, 2018 00:32
-
-
Save aessam/0e954b38ae9cc93edc7efce42858df9a to your computer and use it in GitHub Desktop.
The script takes grabs the title of the active window and print out the amount of time spent on the output file, after that you can use this data to see how much time you spend on each application.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from AppKit import NSWorkspace | |
from time import sleep | |
from time import time | |
import sys | |
if len(sys.argv) != 2: | |
sys.exit("Usage: SCRIPT output_file.txt") | |
file = open(sys.argv[1],"a") | |
lastname = "" | |
t = time() | |
while True: | |
activeAppName = NSWorkspace.sharedWorkspace().activeApplication()['NSApplicationName'] | |
if activeAppName != lastname: | |
if lastname: | |
file.write("\n" + "% 10d" % (int(time() - t),) + "\t" + lastname) | |
lastname = activeAppName | |
t = time() | |
file.flush() | |
sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment