From 4b22b13b104d4bf9854f1c4d09fbafef864e73e5 Mon Sep 17 00:00:00 2001 From: TinyAtoms Date: Sat, 1 Aug 2020 19:23:25 -0300 Subject: [PATCH] added old project --- logger.py | 29 +++++++++++++++++++++++++++++ logs.txt | 1 + 2 files changed, 30 insertions(+) create mode 100644 logger.py create mode 100644 logs.txt diff --git a/logger.py b/logger.py new file mode 100644 index 0000000..0c46397 --- /dev/null +++ b/logger.py @@ -0,0 +1,29 @@ +import subprocess +from datetime import datetime +import time + +def get_active_window(): + return subprocess.run(["xdotool", "getwindowfocus", "getwindowname"], capture_output=True).stdout.decode("utf-8") + + +def update(title): + with open("logs.txt", "a") as file: + time = datetime.now().timestamp() + newline = '{}, "{}"\n'.format(time, title[:-1]) + file.write(newline) + +oldwin = get_active_window() +update(oldwin) +while True: + time.sleep(60); + win = get_active_window() + if oldwin != win: + oldwin = win + update(oldwin) + print(oldwin) + + + + + + diff --git a/logs.txt b/logs.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/logs.txt @@ -0,0 +1 @@ +