aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--install.bash11
-rwxr-xr-xsrc/Watcher/commands.py9
-rwxr-xr-xsrc/Watcher/watch_log.py1
-rwxr-xr-xsrc/Watcher/week_analysis.py6
-rwxr-xr-xsrc/bin/watcher46
-rw-r--r--src/service/watcher.service2
6 files changed, 35 insertions, 40 deletions
diff --git a/install.bash b/install.bash
deleted file mode 100644
index 18c8167..0000000
--- a/install.bash
+++ /dev/null
@@ -1,11 +0,0 @@
-sudo cp -r ./src/Watcher /usr/share/
-cp -r ./src/bin/watcher ~/.local/bin/
-sudo chmod +x ~/.local/bin/watcher
-cp -r ./src/service/watcher.service ~/.config/systemd/user/
-systemctl --user enable watcher.service
-systemctl --user start watcher.service
-
-mkdir ~/.cache/Watcher/
-mkdir ~/.cache/Watcher/raw_data/
-mkdir ~/.cache/Watcher/Analysis/
-
diff --git a/src/Watcher/commands.py b/src/Watcher/commands.py
index 4bbd8c2..6228133 100755
--- a/src/Watcher/commands.py
+++ b/src/Watcher/commands.py
@@ -12,7 +12,7 @@ def daily_summary():
rc.prints_report(window_opened, time_spent)
def week_summary():
- W_Y = os.popen('''date +"W%U-%Y"''').read()[0:-1]
+ W_Y = os.popen('''date +"W%V-%Y"''').read()[0:-1]
user = os.getlogin()
filename = "/home/"+user+"/.cache/Watcher/Analysis/"+W_Y+".csv"
with open(filename, 'r') as file:
@@ -21,9 +21,9 @@ def week_summary():
app_usages = dict()
for row in csvreader:
if len(row[0]) == 3:
- week_overview.update({row[0]:row[1]})
+ week_overview.update({row[0]:row[1]}) # Weekday -- screen-time
else:
- app_usages.update({row[1]:row[0]})
+ app_usages.update({row[1]:row[0]}) # app-name -- usage
week_screen_time = "00:00:00"
for x, y in week_overview.items():
@@ -43,3 +43,6 @@ def week_summary():
if x == "":
x = "Home-Screen"
print(" " + Color.GREEN(f'{x:<22}') + '\t ',f'{to.format_time(y):>12}')
+
+if __name__ == "__main__":
+ week_summary()
diff --git a/src/Watcher/watch_log.py b/src/Watcher/watch_log.py
index 98895bf..ad4a4fd 100755
--- a/src/Watcher/watch_log.py
+++ b/src/Watcher/watch_log.py
@@ -50,6 +50,7 @@ def log_creation():
if __name__ == "__main__":
+ os.popen('''python /usr/share/Watcher/week_analysis.py''')
filename = "/home/"+os.getlogin()+"/.cache/Watcher/raw_data/"+get_date()+".csv"
if not(os.path.isfile(filename)):
with open(filename, 'a') as csvfile:
diff --git a/src/Watcher/week_analysis.py b/src/Watcher/week_analysis.py
index 1f064b2..a82b5f3 100755
--- a/src/Watcher/week_analysis.py
+++ b/src/Watcher/week_analysis.py
@@ -10,7 +10,7 @@ def get_dates():
# The start of the week
start = theday - datetime.timedelta(days=weekday)
# build a simple range
- dates = [start + datetime.timedelta(days=d) for d in range(weekday+1)]
+ dates = [start + datetime.timedelta(days=d) for d in range(weekday + 1)]
dates = [str(d) for d in dates]
return dates
@@ -19,7 +19,7 @@ def weekday_from_date(date):
day = os.popen('''date -d "'''+ date + '''" +%a''').read()
return day[0:-1]
-W_Y = os.popen('''date +"W%U-%Y"''').read()[0:-1]
+W_Y = os.popen('''date +"W%V-%Y"''').read()[0:-1]
user = os.getlogin()
filename = "/home/"+user+"/.cache/Watcher/Analysis/"+W_Y+".csv"
with open(filename, "w") as csvfile:
@@ -39,7 +39,7 @@ with open(filename, "w") as csvfile:
for i in dates:
x, y = rc.extract_data(str(i))
- window_opened += x # smth is wrong here
+ window_opened += x
time_spent += y
for x, y in rc.final_report(window_opened, time_spent).items():
csvwriter.writerow([y, x])
diff --git a/src/bin/watcher b/src/bin/watcher
index bd3301c..506fa8c 100755
--- a/src/bin/watcher
+++ b/src/bin/watcher
@@ -1,8 +1,4 @@
-#!/usr/bin/python3
-
-## watcher --start == will starts the process of making csv
-# watcher --daily-summary == will give you your day overview till that point
-# watcher --week-summary == will gives user their week overview of screen time
+#!/usr/bin/python
import os
import sys
@@ -18,28 +14,34 @@ def help_option():
print(Color.YELLOW("OPTIONS"))
print("\t-ds, --day-summary Displays where you have spend your time of that day")
print("\t-ws, --week-summary Displays screen-time of each day of week")
+ print("\t-s, --start It starts taking logs afterwards in following directory ~/.cache/Watcher/raw_data/")
print("\nFor more information see github repo: https://github.com/Waishnav/Watcher and Don't forget to star the repo")
#print("▒▒▒\t▒▒▒\n███")
-arg = sys.argv[1]
-if arg == "-ds" or arg == "--day-summary":
- cmd.daily_summary()
-elif arg == "-ws" or arg == "--week-summary":
- os.popen("python3 /usr/share/Watcher/week_analysis.py")
- cmd.week_summary()
-elif arg == "-h" or arg == "--help":
+try:
+ arg = sys.argv[1]
+ if arg == "-ds" or arg == "--day-summary":
+ cmd.daily_summary()
+ elif arg == "-ws" or arg == "--week-summary":
+ os.popen("python3 /usr/share/Watcher/week_analysis.py")
+ cmd.week_summary()
+ elif arg == "-h" or arg == "--help":
+ help_option()
+ elif arg == "--start":
+ print("Log creations started... \nif you wanna stop it, use keyboard-shortcut (Ctrl+Shift+C)")
+ x.log_creation()
+ elif arg == "--version":
+ print("Version: 1.0")
+ else:
+ print(Color.RED("Wrong")+" [OPTION] choosen. Have a look at the Options!!\n")
+ print(Color.YELLOW("OPTIONS"))
+ print("\t-ds, --day-summary Displays where you have spend your time of that day")
+ print("\t-ws, --week-summary Displays screen-time of each day of week")
+ print("\nFor more information see github repo: https://github.com/Waishnav/Watcher and Don't forget to star the repo")
+
+except IndexError:
help_option()
-elif arg == "--start":
- x.log_creation()
-elif arg == "--version":
- print("Version: 1.0")
-else:
- print(Color.RED("Wrong")+" [OPTION] choosen. Have a look at the Options!!\n")
- print(Color.YELLOW("OPTIONS"))
- print("\t-ds, --day-summary Displays where you have spend your time of that day")
- print("\t-ws, --week-summary Displays screen-time of each day of week")
- print("\nFor more information see github repo: https://github.com/Waishnav/Watcher and Don't forget to star the repo")
#parser = argparse.ArgumentParser(description="Minimal open source screen-time calulator for digitally wellbeing")
#parser.add_argument()
diff --git a/src/service/watcher.service b/src/service/watcher.service
index 50e764b..90bd2a8 100644
--- a/src/service/watcher.service
+++ b/src/service/watcher.service
@@ -2,7 +2,7 @@
Description=Get the perspective from Watcher about your Screen-Time
[Service]
-ExecStart=/bin/python3 /usr/share/Watcher/watch_log.py
+ExecStart=/bin/python /usr/share/Watcher/watch_log.py
Type=simple
Restart=on-failure