From 2a606b947dc318a783cfd202a446c03586a95cf4 Mon Sep 17 00:00:00 2001 From: Waishnav Date: Sat, 17 Sep 2022 05:09:46 +0530 Subject: updated algorithm | update csv at every second --- src/Watcher/analysis.py | 70 ++++++++++++++----------------------- src/Watcher/get_windows.py | 16 +++------ src/Watcher/watch_log.py | 87 +++++++++++++++++++++++++--------------------- 3 files changed, 79 insertions(+), 94 deletions(-) diff --git a/src/Watcher/analysis.py b/src/Watcher/analysis.py index 6e26d29..0e917f8 100755 --- a/src/Watcher/analysis.py +++ b/src/Watcher/analysis.py @@ -4,45 +4,26 @@ from watch_log import get_date import datetime import time_operations as to -def extract_data(date): - user = os.getlogin() - path = "/home/" + user +"/.cache/Watcher/raw_data/" +# creating dictionary to store time spend on each applicaitons on that particular day +def final_report(date): + path = "/home/" + os.getlogin() +"/.cache/Watcher/daily_data/" filename = path + date + ".csv" - l = list() # l = list of (app_name, time spent on app on that session) - d = dict() - - if os.path.isfile(filename): - with open(filename, 'r') as file: - reader = csv.reader(file) - for row in reader: - for column in row: - l.append([column[18::],column[9:17]]) - d.update({column[18::]: "O"}) - else: - None - - d = list(d) # list of app opened on that day - return d, l - -# creating dictionary to store time spend on each applicaitons on that particular day -def final_report(window_opened, time_spent): report = dict() - - for i in window_opened: # i is applications name - time = '00:00:00' - for j in time_spent: # j is list of applicaions_name and time_spent in particular session - if i == j[0]: - time = to.time_addition(j[1], time) - report.update({i:time}) + if os.path.isfile(filename): + with open(filename, 'r') as f: + raw_data = f.readlines() + for x in raw_data: + x = x.split('\t') + a = {x[1][:-1]:x[0]} + report.update(a) #print(report) - if "User-logged-in" in report.keys(): - report.pop("User-logged-in") - if "AFK" in report.keys(): - report.pop("AFK") if "Unknown" in report.keys(): report.pop("Unknown") + return report + +def sort_data(report): # sort report dictonary in decreasing order of Usages sorted_values = [] for x,y in report.items(): @@ -55,9 +36,11 @@ def final_report(window_opened, time_spent): for x, y in report.items(): if to.convert_into_sec(y) == i: sorted_report.update({x:y}) - + del report + del sorted_values return sorted_report + def get_sunday_of_week(week): year = int(week[4:]) week = int(week[1:3]) @@ -84,28 +67,29 @@ def weekly_logs(week = str(os.popen('''date +"W%V-%Y"''').read()[0:-1])): filename = "/home/"+user+"/.cache/Watcher/Analysis/"+week+".csv" with open(filename, "w") as csvfile: csvwriter = csv.writer(csvfile, delimiter='\t') - #csvwriter.writerow(["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]) if os.popen('''date +"W%V-%Y"''').read()[0:-1] == week: dates = week_dates() else: dates = week_dates(get_sunday_of_week(week)) - window_opened = list() - time_spent = list() for i in dates: - window_opened, time_spent = extract_data(i) Total_screen_time = "00:00:00" - for x, y in final_report(window_opened, time_spent).items(): + for x, y in final_report(i).items(): Total_screen_time = to.time_addition(y, Total_screen_time) - csvwriter.writerow([weekday_from_date(i), Total_screen_time]) + all_data = dict() for i in dates: - x, y = extract_data(str(i)) - window_opened += x - time_spent += y - for x, y in final_report(window_opened, time_spent).items(): + for x, y in final_report(i).items(): + usage = all_data.get(x) + if usage == None: + usage = "00:00:00" + y = to.time_addition(usage, y) + all_data.update({x:y}) + + all_data = sort_data(all_data) + for x, y in all_data.items(): csvwriter.writerow([y, x]) #testing diff --git a/src/Watcher/get_windows.py b/src/Watcher/get_windows.py index 0769eb9..008defa 100755 --- a/src/Watcher/get_windows.py +++ b/src/Watcher/get_windows.py @@ -42,18 +42,10 @@ def active_window(): return active_window # returns true if user has move to next app which is not the same as previous -def is_window_changed(a, afk, timeout): - result = False - while not(result): - time.sleep(0.5) - b = active_window() - if a != b : - result = True - elif get_afk_status(afk, timeout): - result = True - else: - result = False - return result +def previous_window(array_of_window, active_window): + array_of_window.remove(active_window) + array_of_window.append(active_window) + return l[-2] ### what to do after window get change I've to append one line in csv data file in following format diff --git a/src/Watcher/watch_log.py b/src/Watcher/watch_log.py index cc85a23..a221194 100755 --- a/src/Watcher/watch_log.py +++ b/src/Watcher/watch_log.py @@ -3,7 +3,7 @@ import csv import time import get_windows as x import afk as y -from time_operations import time_difference +from time_operations import time_difference, time_addition, convert # get current time whenever the function is called def get_time(): @@ -15,59 +15,68 @@ def get_date(): d = os.popen('''date +"%Y-%m-%d"''').read() return d[0:-1] -def append_line_in_csv(date, opened_time, closed_time, window_name): +def update_csv(date, Data): user = os.getlogin() - time_spent = time_difference(opened_time, closed_time) - filename = "/home/"+os.getlogin()+"/.cache/Watcher/raw_data/"+date+".csv" - Data = [closed_time, time_spent, window_name] - with open(filename, 'a') as csvfile: + filename = "/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+date+".csv" + overwrite_Data = [] + with open(filename, 'w') as csvfile: + for x,y in Data.items(): + overwrite_Data.append([y,x]) + csvwriter = csv.writer(csvfile, delimiter='\t') - csvwriter.writerow(Data) + csvwriter.writerows(overwrite_Data) # Expected Behaviour == if date got changed then append line in new csv file after initializing the csv file # also if usr is AFK then append line +def import_data(file): + with open(file, 'r') as f: + raw_data = f.readlines() + data = dict() + #l = [] + for x in raw_data: + x = x.split('\t') + a = {x[1][:-1]:x[0]} + #l.append(x[1][:-1]) + data.update(a) + return data + # TODO: AFK feature devlopement (it will be developed after completing alpha product (after whole project up end running) def log_creation(): - filename = "/home/"+os.getlogin()+"/.cache/Watcher/raw_data/"+get_date()+".csv" + filename = "/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+get_date()+".csv" if not(os.path.isfile(filename)): - with open(filename, 'a') as csvfile: - csvwriter = csv.writer(csvfile, delimiter='\t') - csvwriter.writerow([get_time(), "00:00:00", ""]) - logout_time = os.popen("tail -n1 " + filename).read().split("\t")[0] - append_line_in_csv(get_date(), logout_time, get_time(), "User-logged-in") + os.popen("touch " + filename) afk = False - afkTimeout = 3 # timeout in minutes - + afkTimeout = 1 # timeout in minutes + data = import_data(filename) while True: - opened_at = get_time() - previous_window = x.active_window() + date = get_date() + filename = "/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+date+".csv" + afk = y.is_afk(afkTimeout) - if (y.returned_from_afk(afk, afkTimeout)): - previous_window = "AFK" - if os.path.exists(filename): - opened_at = os.popen(" tail -n1 "+ filename).read().split("\t")[0] - else: - previous_date = os.popen("""date -d "1 day ago" '+%Y-%m-%d'""").read()[:-1] - opened_at = os.popen(" tail -n1 ~/.cache/Watcher/raw_data/"+previous_date+".csv").read().split("\t")[0] - afk = False + if not(afk): + active_window = x.active_window() + usage = data.get(active_window) + if usage == None: + usage = "00:00:00" - if (x.is_window_changed(previous_window, afk, afkTimeout) and not afk): - if(y.is_afk(afkTimeout)): - afk = True - # minimizing error - closed_at = time_difference("00:02:58", get_time()) - else: - closed_at = get_time() # for next_window its the opening time + time.sleep(1) + if y.is_afk(afkTimeout): + afk_time = int(round(int(os.popen("xprintidle").read()[:-1])/1000, 0)) + usage = time_difference(convert(afk_time), usage) - date = get_date() - filename = "/home/"+os.getlogin()+"/.cache/Watcher/raw_data/"+date+".csv" - append_line_in_csv(date, opened_at, closed_at, previous_window) + usage = time_addition("00:00:01", usage) + data.update({active_window : usage}) + if os.path.isfile("/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+date+".csv"): + update_csv(get_date(), data) + elif not(os.path.isfile("/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+date+".csv")): + os.popen("touch " + "/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+date+".csv") + data.clear() if __name__ == "__main__": - #log_creation() - filename = "/home/"+os.getlogin()+"/.cache/Watcher/raw_data/"+get_date()+".csv" - opened_at = os.popen(" tail -n1 "+ filename).read().split("\t")[0] - print(opened_at) + log_creation() + #afk_time = int(round(int(os.popen("xprintidle").read()[:-1])/1000, 0)) + #print(afk_time) + -- cgit v1.2.3 From 9fd05fa5f70164aaa7df70bdf4b6b467f7108f22 Mon Sep 17 00:00:00 2001 From: Waishnav Date: Sat, 17 Sep 2022 06:37:49 +0530 Subject: removed outdated comment --- src/Watcher/get_windows.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Watcher/get_windows.py b/src/Watcher/get_windows.py index 008defa..c22d909 100755 --- a/src/Watcher/get_windows.py +++ b/src/Watcher/get_windows.py @@ -1,7 +1,13 @@ import os import time +import platform from afk import get_afk_status +if platform.system() == 'Windows': + from win32gui import GetWindowText, GetForegroundWindow +elif platform.system() == 'Darwin': + import subprocess + # get title name of app that user working on def active_window_title(): active_window_title = os.popen('''xprop -id $(xdotool getwindowfocus) WM_NAME''').read()[19:-2] @@ -47,13 +53,3 @@ def previous_window(array_of_window, active_window): array_of_window.append(active_window) return l[-2] - -### what to do after window get change I've to append one line in csv data file in following format -### opened-time closed-time time-spent window_class_name window_title_name - -### and whenever the user puts particular command it will make report till the time for that day and shows that report in terminal -if __name__ == "__main__": - while True: - time.sleep(1) - print(active_window_title()) - print(os.popen('''xdotool getwindowfocus getwindowname''').read()) -- cgit v1.2.3 From f0636d1ac0201686b22f252f3b7eaba7879553b6 Mon Sep 17 00:00:00 2001 From: Waishnav Date: Sat, 17 Sep 2022 06:39:45 +0530 Subject: compensating error value changed --- src/Watcher/afk.py | 2 +- src/Watcher/time_operations.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Watcher/afk.py b/src/Watcher/afk.py index 41f8fe9..3d92068 100755 --- a/src/Watcher/afk.py +++ b/src/Watcher/afk.py @@ -15,7 +15,7 @@ def returned_from_afk(afk_active, timeout): return has_returned def is_afk(timeout): - timeout = timeout * 60 * 1000 - 200 # minimizing 200 milisec error + timeout = timeout * 60 * 1000 - 100 # minimizing 100 milisec error #If the AFK feature is installed time_since_last_input = int(os.popen("xprintidle").read()[:-1]) if (time_since_last_input > timeout): diff --git a/src/Watcher/time_operations.py b/src/Watcher/time_operations.py index 1df4922..5042983 100755 --- a/src/Watcher/time_operations.py +++ b/src/Watcher/time_operations.py @@ -66,4 +66,17 @@ def convert_into_sec(t): sec = int(t[0:2])*3600 + int(t[3:5])*60 + int(t[6::]) return sec +def convert(sec): + sec = int(sec) + sec = sec % (24 * 3600) + hr = sec // 3600 + sec %= 3600 + mn = sec // 60 + sec %= 60 + hr = str(hr).zfill(2) + mn = str(mn).zfill(2) + sec = str(sec).zfill(2) + + result = hr + ":" + mn + ":" + sec + return result -- cgit v1.2.3 From e03da70c3406b4e0ad9646b55922aec3c49f8c66 Mon Sep 17 00:00:00 2001 From: Waishnav Date: Sat, 17 Sep 2022 06:42:59 +0530 Subject: changed function according to 2.0 analysis function --- src/Watcher/commands.py | 5 ++--- src/bin/watcher | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Watcher/commands.py b/src/Watcher/commands.py index 7d1fe97..8805dac 100755 --- a/src/Watcher/commands.py +++ b/src/Watcher/commands.py @@ -35,9 +35,8 @@ class Color: return '\033[4m' + text + '\033[0m' def daily_summary(date = get_date()): - window_opened, time_spent = anls.extract_data(date) Total_screen_time = "00:00:00" - for x,y in anls.final_report(window_opened, time_spent).items(): + for x,y in anls.final_report(date).items(): Total_screen_time = to.time_addition(y, Total_screen_time) if date == get_date(): @@ -66,7 +65,7 @@ def daily_summary(date = get_date()): print(Color.RED(f'{" App Usages":>29}')) print(" ────────────────────────────────────────────────") - for x,y in anls.final_report(window_opened, time_spent).items(): + for x,y in anls.sort_data(anls.final_report(date)).items(): if x == "": x = "Home-Screen" print(" " + Color.GREEN(f'{x:<22}') + '\t ',f'{to.format_time(y):>12}') diff --git a/src/bin/watcher b/src/bin/watcher index 2644fd1..e02e9a3 100755 --- a/src/bin/watcher +++ b/src/bin/watcher @@ -46,7 +46,7 @@ if len(arg) == 2: print("Log creations started... \nif you wanna stop it, use keyboard-shortcut (Ctrl+Shift+C or Ctrl+C)") x.log_creation() elif arg[1] == "--version" or arg[1] == "-v": - print("Version: 1.3.1") + print("Version: 2.0.0") else: wrong_option() -- cgit v1.2.3 From b95a2ca20ba884934b0301b8cc245c7e16e8bb11 Mon Sep 17 00:00:00 2001 From: Waishnav Date: Sat, 17 Sep 2022 06:45:23 +0530 Subject: export python script for watcher v1.2 version csv files --- misc/export_to_2.0 | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100755 misc/export_to_2.0 diff --git a/misc/export_to_2.0 b/misc/export_to_2.0 new file mode 100755 index 0000000..ef30ffe --- /dev/null +++ b/misc/export_to_2.0 @@ -0,0 +1,83 @@ +#!/usr/bin/python +import os +import sys +sys.path.insert(0, "/usr/share/Watcher/") +import csv +from watch_log import get_date +import datetime +import time_operations as to + +def extract_data(date): + user = os.getlogin() + path = "/home/" + user +"/.cache/Watcher/raw_data/" + filename = path + date + ".csv" + + l = list() # l = list of (app_name, time spent on app on that session) + d = dict() + + if os.path.isfile(filename): + with open(filename, 'r') as file: + reader = csv.reader(file) + for row in reader: + for column in row: + l.append([column[18::],column[9:17]]) + d.update({column[18::]: "O"}) + else: + None + + d = list(d) # list of app opened on that day + return d, l + +# creating dictionary to store time spend on each applicaitons on that particular day +def final_report(window_opened, time_spent): + report = dict() + + for i in window_opened: # i is applications name + time = '00:00:00' + for j in time_spent: # j is list of applicaions_name and time_spent in particular session + if i == j[0]: + time = to.time_addition(j[1], time) + report.update({i:time}) + + #print(report) + if "User-logged-in" in report.keys(): + report.pop("User-logged-in") + if "AFK" in report.keys(): + report.pop("AFK") + if "Unknown" in report.keys(): + report.pop("Unknown") + # sort report dictonary in decreasing order of Usages + sorted_values = [] + for x,y in report.items(): + sorted_values.append(to.convert_into_sec(y)) + + sorted_values.sort(reverse=True) + sorted_report = dict() + + for i in sorted_values: + for x, y in report.items(): + if to.convert_into_sec(y) == i: + sorted_report.update({x:y}) + + return sorted_report + +def export_to_new(date): + window_opened, time_spent = extract_data(date) + sorted_report = final_report(window_opened, time_spent) + filename = "/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+date+".csv" + overwrite_Data = [] + with open(filename, 'w') as csvfile: + for x,y in sorted_report.items(): + overwrite_Data.append([y,x]) + + csvwriter = csv.writer(csvfile, delimiter='\t') + csvwriter.writerows(overwrite_Data) + + del sorted_report + del overwrite_Data + +path = "/home/" + os.getlogin() +"/.cache/Watcher/raw_data/" +for file in os.listdir(path): + export_to_new(file[:-4]) + + -- cgit v1.2.3 From abefc10eedc1f71d791ea86394fd749a3d8b5e0d Mon Sep 17 00:00:00 2001 From: Waishnav Date: Tue, 11 Oct 2022 03:44:14 +0530 Subject: cleaning documentation stuffs | making it pure dev-branch for v2.0 --- README.md | 40 ---------------------------------------- src/bin/watcher | 2 +- 2 files changed, 1 insertion(+), 41 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 353c5a3..0000000 --- a/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# Watcher -### Minimal Open source Screen-Time Tracker (CLI-app) - - -## Table of Contents - -- [About](#about) -- [Gallery](#gallery) -- [Installation](#installation) -- [Todo](#to-do) - -## About -Watcher is CLI-app (at this moment) which helps you to get perspective about your Screen-time - -## Gallery -Day Summary | Week Summary -:-------------------------:|:-------------------------: -![](https://cdn.discordapp.com/attachments/846673042893832195/952283314746691624/unknown.png) | ![](https://cdn.discordapp.com/attachments/846673042893832195/952283190716948521/unknown.png) - -Funfact: You might be thinking how can someone has 14 hrs of screen time in a single day, Well ! short ans is AFK-feature is not implemented yet... Most of the time I left my laptop as it is so it also counts that AFK time as Screen-time - -## Installation -* Note: Install [```xprintidle```](https://github.com/g0hl1n/xprintidle) and [```xdotool```](https://github.com/jordansissel/xdotool) on your system ( its the only dependancy ) -* First, Install the following dependancy ```xprintidle``` and ```xdotool``` -```bash -$ sudo [package-manager] install xprintidle xdotool -``` -* Second, Clone this repository and cd into it- -```bash -$ git clone https://github.com/Waishnav/Watcher -$ cd ./Watcher/ -``` -* Then run install script -```bash -$ chmod +x ./install && ./install -``` - -## To-do -- [x] AFK feature -- [ ] GUI only if got 300 stars Probably [Tauri App](https://github.com/tauri-apps/tauri). diff --git a/src/bin/watcher b/src/bin/watcher index e02e9a3..0dde744 100755 --- a/src/bin/watcher +++ b/src/bin/watcher @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import os import sys sys.path.insert(0, "/usr/share/Watcher/") -- cgit v1.2.3 From 096138c06eb6d8db6584039584b49ed5cd4d6f39 Mon Sep 17 00:00:00 2001 From: Pawan Patil <63651567+PawanPatil19@users.noreply.github.com> Date: Thu, 20 Oct 2022 03:42:22 +0800 Subject: fix : v2.0 Issue to avoid replication of data as day changed --- src/Watcher/watch_log.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Watcher/watch_log.py b/src/Watcher/watch_log.py index a221194..0d2095a 100755 --- a/src/Watcher/watch_log.py +++ b/src/Watcher/watch_log.py @@ -46,7 +46,9 @@ def import_data(file): def log_creation(): filename = "/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+get_date()+".csv" if not(os.path.isfile(filename)): - os.popen("touch " + filename) + creat_file = "/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+get_date()+".csv" + with open(creat_file, 'w') as fp: + pass afk = False afkTimeout = 1 # timeout in minutes @@ -69,11 +71,15 @@ def log_creation(): usage = time_addition("00:00:01", usage) data.update({active_window : usage}) - if os.path.isfile("/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+date+".csv"): + if os.path.isfile("/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+get_date()+".csv"): update_csv(get_date(), data) - elif not(os.path.isfile("/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+date+".csv")): - os.popen("touch " + "/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+date+".csv") + elif not(os.path.isfile("/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+get_date()+".csv")): + new_filename = "/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+get_date()+".csv" + with open(new_filename, 'w') as fp: + pass + data.clear() + if __name__ == "__main__": log_creation() -- cgit v1.2.3 From 5759b3af2f95486a6009a96ea3a9992485185ce8 Mon Sep 17 00:00:00 2001 From: Pawan Patil <63651567+PawanPatil19@users.noreply.github.com> Date: Thu, 20 Oct 2022 03:44:09 +0800 Subject: fix: Change directory from 'raw_data' to 'daily_data' --- install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install b/install index dedccfa..293352c 100755 --- a/install +++ b/install @@ -18,7 +18,7 @@ echo "[✔] Making it executable by giving it permission" # making directory for log-files (where all you daily logs are stored) mkdir -p ~/.cache/Watcher/ echo "[✔] To store raw_data making directory as ~/.cache/Watcher" -mkdir -p ~/.cache/Watcher/raw_data/ +mkdir -p ~/.cache/Watcher/daily_data/ mkdir -p ~/.cache/Watcher/Analysis/ # deleting folowing lines "[ -f /etc/xprofile ] && . /etc/xprofile/" and "[ -f ~/.xprofile ] && . ~/.xprofile" -- cgit v1.2.3 From 0386f0b5bd6a58248087ad5cf12051094277f074 Mon Sep 17 00:00:00 2001 From: Waishnav Date: Mon, 14 Nov 2022 11:02:44 +0530 Subject: making easy to installation link using curl --- install | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install b/install index 293352c..e5043cb 100755 --- a/install +++ b/install @@ -1,5 +1,9 @@ #!/bin/bash +git clone https://github.com/Waishnav/Watcher -b v2.0 +cd Watcher +./install + echo "[✔] First of all Thanks for dropping by!." sleep 1s echo "[✔] And...FYI Watcher uses very less resources like almost 10 MBs." -- cgit v1.2.3 From 4c214e401abc4d7d4c9a7182348b6bebf78de34a Mon Sep 17 00:00:00 2001 From: Waishnav Date: Mon, 14 Nov 2022 11:03:06 +0530 Subject: changed some variable names --- src/Watcher/get_windows.py | 12 +++--------- src/Watcher/watch_log.py | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Watcher/get_windows.py b/src/Watcher/get_windows.py index c22d909..a0be469 100755 --- a/src/Watcher/get_windows.py +++ b/src/Watcher/get_windows.py @@ -1,12 +1,4 @@ import os -import time -import platform -from afk import get_afk_status - -if platform.system() == 'Windows': - from win32gui import GetWindowText, GetForegroundWindow -elif platform.system() == 'Darwin': - import subprocess # get title name of app that user working on def active_window_title(): @@ -51,5 +43,7 @@ def active_window(): def previous_window(array_of_window, active_window): array_of_window.remove(active_window) array_of_window.append(active_window) - return l[-2] + return array_of_window[-2] +if __name__ == "__main__": + print(active_window()) diff --git a/src/Watcher/watch_log.py b/src/Watcher/watch_log.py index 0d2095a..6a44ca5 100755 --- a/src/Watcher/watch_log.py +++ b/src/Watcher/watch_log.py @@ -16,7 +16,6 @@ def get_date(): return d[0:-1] def update_csv(date, Data): - user = os.getlogin() filename = "/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+date+".csv" overwrite_Data = [] with open(filename, 'w') as csvfile: @@ -57,6 +56,7 @@ def log_creation(): date = get_date() filename = "/home/"+os.getlogin()+"/.cache/Watcher/daily_data/"+date+".csv" afk = y.is_afk(afkTimeout) + print(data) if not(afk): active_window = x.active_window() -- cgit v1.2.3 From ac72b6cdab6a7dfc6aed570a559688ee33292ac6 Mon Sep 17 00:00:00 2001 From: Waishnav Date: Mon, 14 Nov 2022 19:26:12 +0530 Subject: Error in installtion --- install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install b/install index e5043cb..e55fe44 100755 --- a/install +++ b/install @@ -1,6 +1,6 @@ #!/bin/bash -git clone https://github.com/Waishnav/Watcher -b v2.0 +git clone https://github.com/Waishnav/Watcher -b v2.0 && cd Watcher ./install -- cgit v1.2.3 From 64f239a85f370a79e6b8fec84f3a2d4c095eea03 Mon Sep 17 00:00:00 2001 From: Waishnav Date: Mon, 14 Nov 2022 19:30:08 +0530 Subject: Error in installtion solved --- Watcher | 1 + install | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) create mode 160000 Watcher diff --git a/Watcher b/Watcher new file mode 160000 index 0000000..ac72b6c --- /dev/null +++ b/Watcher @@ -0,0 +1 @@ +Subproject commit ac72b6cdab6a7dfc6aed570a559688ee33292ac6 diff --git a/install b/install index e55fe44..310071d 100755 --- a/install +++ b/install @@ -1,8 +1,5 @@ #!/bin/bash - -git clone https://github.com/Waishnav/Watcher -b v2.0 && -cd Watcher -./install +git clone https://github.com/Waishnav/Watcher -b v2.0 && cd Watcher && ./install echo "[✔] First of all Thanks for dropping by!." sleep 1s -- cgit v1.2.3 From 212a5aaf5c1b2b2b956d75c4ba66c95222e31683 Mon Sep 17 00:00:00 2001 From: Vaishnav Deore <86405648+Waishnav@users.noreply.github.com> Date: Mon, 14 Nov 2022 20:17:21 +0530 Subject: resolving conflict --- README.md | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..244e822 --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +# Watcher + +### Minimal Open source Screen-Time Tracker (CLI-app) + + + +## Table of Contents + +- [About](#about) +- [Gallery](#gallery) +- [Installation](#installation) +- [Want to Contribute](#want-to-contribute) +- [Todo](#to-do) + + +## About + +Watcher is CLI-app (at this moment) which helps you to get perspective about your Screen-time + +## Gallery + +| Day Summary | Week Summary | +| :-------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------: | +| ![](https://cdn.discordapp.com/attachments/846673042893832195/952283314746691624/unknown.png) | ![](https://cdn.discordapp.com/attachments/846673042893832195/952283190716948521/unknown.png) | + +Funfact: You might be thinking how can someone has 14 hrs of screen time in a single day, Well ! short ans is AFK-feature is not implemented yet... Most of the time I left my laptop as it is so it also counts that AFK time as Screen-time + +## Installation + +- Note: Install [`xprintidle`](https://github.com/g0hl1n/xprintidle) and [`xdotool`](https://github.com/jordansissel/xdotool) on your system ( the only dependancies other than python3 ). Install [`python3`](https://www.python.org/downloads/) if not installed in your machine. +- First, Install the following dependancy `xprintidle` and `xdotool` + +```bash +$ sudo [package-manager] install xprintidle xdotool +``` + +- Second, Clone this repository and cd into it- + +```bash +$ git clone https://github.com/Waishnav/Watcher +$ cd ./Watcher/ +``` + +- Then run install script + +```bash +$ chmod +x ./install && ./install +``` + +### Want to Contribute +If you are interseted in contibuting checkout [CONTRIBUTING.md](https://github.com/Waishnav/Watcher/blob/main/CONTRIBUTING.md) + +You can currently contribute to one of the three projects listed below throughout the HACTOBERFEST. +- [Watcher Website](https://github.com/Waishnav/Watcher-web) (made with React) +- [Watcher v1.0](https://github.com/Waishnav/Watcher/tree/v1.0) (No real time updates in logfile) +- [Watcher v2.0](https://github.com/Waishnav/Watcher/tree/v2.0) (Real time stats in logfile) + +To contribute, clone the relevant branch anywhere you wish to. + +## To-do + +- [x] AFK feature +- [ ] GUI only if got 300 stars Probably [Tauri App](https://github.com/tauri-apps/tauri). -- cgit v1.2.3