diff options
| author | DemonKingSwarn <rockingswarn@gmail.com> | 2025-02-03 17:54:58 +0530 |
|---|---|---|
| committer | DemonKingSwarn <rockingswarn@gmail.com> | 2025-02-03 20:21:07 +0530 |
| commit | f73809fd04fbb62d24f8e55549c0871dad2cb653 (patch) | |
| tree | ffae7617c0ea6f1581ef9f713c638467b1f22f57 /src/GetWindowsv2.cs | |
| parent | 3405b97815100248400df158dcede0ee21f20250 (diff) | |
| download | hypr-wellbeing-f73809fd04fbb62d24f8e55549c0871dad2cb653.zip hypr-wellbeing-f73809fd04fbb62d24f8e55549c0871dad2cb653.tar.gz | |
chore: project rename `hyprwatch` -> `hypr-wellbeing`
Diffstat (limited to 'src/GetWindowsv2.cs')
| -rw-r--r-- | src/GetWindowsv2.cs | 21 |
1 files changed, 8 insertions, 13 deletions
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>>([^,]+)")] |
