diff options
| author | DemonKingSwarn <rockingswarn@gmail.com> | 2025-01-25 18:29:18 +0530 |
|---|---|---|
| committer | DemonKingSwarn <rockingswarn@gmail.com> | 2025-01-25 18:29:18 +0530 |
| commit | e9a36d9a3cc50105ade148e0f8a286f89ac0c4df (patch) | |
| tree | e546efe1daf970f467d3040e3818e528600bd05c /src/GetWindows.cs | |
| download | hypr-wellbeing-e9a36d9a3cc50105ade148e0f8a286f89ac0c4df.zip hypr-wellbeing-e9a36d9a3cc50105ade148e0f8a286f89ac0c4df.tar.gz | |
chore: main logger done
Diffstat (limited to 'src/GetWindows.cs')
| -rw-r--r-- | src/GetWindows.cs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/GetWindows.cs b/src/GetWindows.cs new file mode 100644 index 0000000..d2bba9f --- /dev/null +++ b/src/GetWindows.cs @@ -0,0 +1,47 @@ +namespace hyprwatch.Window +{ + using System; + using System.Diagnostics; + using System.Text.RegularExpressions; + + public class GetWindows + { + public static string ActiveWindow() + { + string? activeWindow = null; + + try { + Process process = new Process + { + StartInfo = new ProcessStartInfo + { + FileName = "hyprctl", + Arguments = "activewindow", + RedirectStandardOutput = true, + UseShellExecute = false, + CreateNoWindow = true, + } + }; + + process.Start(); + + string output = process.StandardOutput.ReadToEnd(); + process.WaitForExit(); + + var classMatch = Regex.Match(output, @"class:(.+)"); + + if(classMatch.Success) + { + activeWindow = classMatch.Groups[1].Value.Trim(); + } + } + catch(Exception ex) + { + Console.WriteLine(ex.Message); + } + + return activeWindow; + } + } + +} |
