From ac70491939ab9dce5cce45c8c3403cd332736d98 Mon Sep 17 00:00:00 2001 From: DemonKingSwarn Date: Mon, 3 Feb 2025 17:54:58 +0530 Subject: chore: project rename `hyprwatch` -> `hypr-wellbeing` --- README.md | 2 +- src/GetWindowsv2.cs | 21 ++++++++------------- src/WatchLog.cs | 3 ++- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 62ef9b8..40c1d78 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# hyprwatch +# hypr-wellbeing ![](./.assets/show.png) diff --git a/src/GetWindowsv2.cs b/src/GetWindowsv2.cs index 7185776..ea61cb7 100644 --- a/src/GetWindowsv2.cs +++ b/src/GetWindowsv2.cs @@ -15,7 +15,7 @@ namespace hyprwatch.Window string socketPath = Path.Combine(xdgRuntimeDir, "hypr", hyprlandInstanceSig, ".socket2.sock"); - string activeWindow = "Home-Screen"; + string? activeWindow = null; var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP); @@ -26,22 +26,17 @@ namespace hyprwatch.Window using (var stream = new NetworkStream(socket)) using (var reader = new StreamReader(stream)) { - while (true) - { string line = reader.ReadLine(); - if (line == null) + if (line != null) { - break; - } - var classMatch = ClassRegex().Match(line); - if(classMatch.Success) - { - activeWindow = classMatch.Groups[1].Value.Trim(); - break; + var classMatch = ClassRegex().Match(line); + if(classMatch.Success) + { + activeWindow = classMatch.Groups[1].Value.Trim(); + } } - } } } catch (Exception ex) @@ -53,7 +48,7 @@ namespace hyprwatch.Window socket.Close(); } - return activeWindow; + return activeWindow ?? "Home-Screen"; } [GeneratedRegex(@"activewindow>>([^,]+)")] diff --git a/src/WatchLog.cs b/src/WatchLog.cs index 9191aa0..cb2aa7a 100644 --- a/src/WatchLog.cs +++ b/src/WatchLog.cs @@ -165,9 +165,10 @@ namespace hyprwatch.Logger } } - Console.WriteLine(data); + //Console.WriteLine(data); string activeWindow = GetWindows.ActiveWindow(); + Console.WriteLine(activeWindow); string usage = data.TryGetValue(activeWindow, out string? value) ? value : "00:00:00"; Thread.Sleep(1000); -- cgit v1.1