#!/usr/bin/python3 import os import sys sys.path.insert(0, "/usr/share/Watcher/") import watch_log as x from commands import Color import commands as cmd from analysis import weekly_logs def help_option(): print(Color.BLUE("Watcher") + " - Minimal open source screen-time tracker\n") print(Color.YELLOW("USAGE:")+"\n\t watcher [OPTION]\n") print(Color.YELLOW("OPTIONS")) print("\t-ds, --day-summary Shows today's screen-time and app-usage") print("\t-ds [date] Shows that day's screen-time and app-usage\n\t\t\t\t\t (if date is not given then date=today's date)") print("\t-ws, --week-summary Shows screen-time of each day of that running week") print("\t-ws [week] Shows screen-time of each day of that week given by you") print("\t-s, --start It starts taking logs afterwards in following directory ~/.cache/Watcher/raw_data/") print(Color.YELLOW("\nEXAMPLE COMMANDS")) print("\twatcher -ds 2022-01-31") print("\twatcher -ws W01-2022") print("\nFor more information see github repo: "+ Color.BLUE("https://github.com/Waishnav/Watcher") +" and Don't forget to star the repo") def wrong_option(): print(Color.RED("Wrong")+" [OPTION] choosen. Have a look at the Options!!\n") print(Color.YELLOW("OPTIONS")) print("\t-ds or --day-summary [date] Displays where you have spend your time of that day") print("\t-ws or --week-summary [week] Displays screen-time of each day of week") print(Color.YELLOW("\nEXAMPLE COMMANDS")) print("\twatcher -ds 2022-01-31") print("\twatcher -ws W01-2022") print("\nFor more information see github repo: "+ Color.BLUE("https://github.com/Waishnav/Watcher") +" and Don't forget to star the repo") #print("▒▒▒\t▒▒▒\n███") arg = sys.argv if len(arg) == 2: if arg[1] == "-ds" or arg[1] == "--day-summary": cmd.daily_summary() elif arg[1] == "-ws" or arg[1] == "--week-summary": weekly_logs() cmd.week_summary() elif arg[1] == "-h" or arg[1] == "--help": help_option() elif arg[1] == "--start" or arg[1] == "-s": print("Log creations started... \nif you wanna stop it, use keyboard-shortcut (Ctrl+Shift+C or Ctrl+C)") try: x.log_creation() except KeyboardInterrupt: exit(0) elif arg[1] == "--version" or arg[1] == "-v": print("Version: 2.0.0") else: wrong_option() elif len(arg) == 3: if arg[1] == "-ds" or arg[1] == "--day-summary": if len(arg[2]) == 10: cmd.daily_summary(str(arg[2])) elif arg[2] == "--yestarday" or arg[2] == "-y": cmd.daily_summary(os.popen("""date -d "1 day ago" '+%Y-%m-%d'""").read()[:-1]) else: wrong_option() elif arg[1] == "-ws" or arg[1] == "--week-summary": if len(arg[2]) == 8: weekly_logs(str(arg[2])) cmd.week_summary(str(arg[2])) elif arg[2] == "--previous_week" or arg[2] == "-pw": prev_week=os.popen("""date -d 'last week' '+W%W-%Y'""").read()[:-1] weekly_logs(prev_week) cmd.week_summary(prev_week) else: wrong_option() else: wrong_option() else: wrong_option() #parser = argparse.ArgumentParser(description="Minimal open source screen-time calulator for digitally wellbeing") #parser.add_argument() #args = parser.parse_args() #print(args)