aboutsummaryrefslogtreecommitdiff
path: root/Program.cs
blob: 5cd262a8b9efa2ee226552aea4f9a1a65dfc6cfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System.IO;
using System.Runtime.InteropServices;
using hyprwatch.Logger;

class Program
{
    static void Main(string[] args)
  {
    if (args.Length == 0 || args[0] != "-d" && args[0] != "--show")
    {
      Console.WriteLine("Usage: -d || --show");
      return;
    }

    if(args[0] == "-d")
    {
        while(true)
        {
          WatchLog.LogCreation();
          System.Threading.Thread.Sleep(5000);
        }
    }

    if(args[0] == "--show")
    {
      string green = "\x1b[0;32m";
      string yellow = "\x1b[1;33m";
      string red = "\x1b[0;31m";
      string blue = "\x1b[0;34m";
      string reset = "\x1b[0m";

      Dictionary<string, string> data = new Dictionary<string, string>();

      var date = WatchLog.GetDate(); 
      string filePath = Environment.GetEnvironmentVariable("HOME") + $"/.cache/hyprwatch/daily_data/{date}.csv";

      var rawData = File.ReadAllLines(filePath);

      foreach(var line in rawData)
      {
        var parts = line.Split('\t');
        if(parts.Length >= 2)
        {
          string key = parts[1].TrimEnd();
          string value = parts[0];
          data[key] = value;
        }
      }
      Console.WriteLine($"{yellow}{"App",-30}{"Time",30}{reset}");
      Console.WriteLine($"{red}{new string('-', 60)}{reset}");
      foreach (var entry in data)
      {
        Console.WriteLine($"{blue}{entry.Key,-30}{reset}{green}{entry.Value,30}{reset}");
      }
    }
  }

}