aboutsummaryrefslogtreecommitdiff
path: root/src/GetWindows.cs
diff options
context:
space:
mode:
authorDemonKingSwarn <rockingswarn@gmail.com>2025-06-14 23:21:56 +0530
committerDemonKingSwarn <rockingswarn@gmail.com>2025-06-14 23:21:56 +0530
commit333f7d1f4757855cbdb84e51ac64f52be226e753 (patch)
treef47698f74f66b62c1c563c4ade4eb04a799134fa /src/GetWindows.cs
parent9412a9611fa3cc22626f3ebfb1f69000ab76416d (diff)
downloadhypr-wellbeing-333f7d1f4757855cbdb84e51ac64f52be226e753.zip
hypr-wellbeing-333f7d1f4757855cbdb84e51ac64f52be226e753.tar.gz
chore: added niri support
Diffstat (limited to 'src/GetWindows.cs')
-rw-r--r--src/GetWindows.cs49
1 files changed, 36 insertions, 13 deletions
diff --git a/src/GetWindows.cs b/src/GetWindows.cs
index e110760..ee72c39 100644
--- a/src/GetWindows.cs
+++ b/src/GetWindows.cs
@@ -1,4 +1,4 @@
-namespace hyprwatch.Window
+namespace hyprwatch.Window
{
using System;
using System.Diagnostics;
@@ -8,20 +8,28 @@ namespace hyprwatch.Window
{
public static string ActiveWindow()
{
+ string desktopEnv = Environment.GetEnvironmentVariable("XDG_CURRENT_DESKTOP");
string? activeWindow = null;
try {
- Process process = new Process
+ Process process = new Process();
+ process.StartInfo = new ProcessStartInfo();
+
+ process.StartInfo.RedirectStandardOutput = true;
+ process.StartInfo.UseShellExecute = false;
+ process.StartInfo.CreateNoWindow = true;
+
+
+ if(desktopEnv == "Hyprland")
{
- StartInfo = new ProcessStartInfo
- {
- FileName = "hyprctl",
- Arguments = "activewindow",
- RedirectStandardOutput = true,
- UseShellExecute = false,
- CreateNoWindow = true,
- }
- };
+ process.StartInfo.FileName = "hyprctl";
+ process.StartInfo.Arguments = "activewindow";
+ }
+ else if(desktopEnv == "niri")
+ {
+ process.StartInfo.FileName = "niri";
+ process.StartInfo.Arguments = "msg focused-window";
+ }
process.Start();
@@ -30,10 +38,25 @@ namespace hyprwatch.Window
var classMatch = ClassRegex().Match(output);
- if(classMatch.Success)
+ if(desktopEnv == "niri")
+ {
+ var match = Regex.Match(output, "App ID:\\s+\"([^\"]+)\"");
+ if(match.Success)
+ {
+ activeWindow = match.Groups[1].Value.Trim();
+ }
+ }
+
+
+ if(desktopEnv == "Hyprland")
{
- activeWindow = classMatch.Groups[1].Value.Trim();
+ if(classMatch.Success)
+ {
+ activeWindow = classMatch.Groups[1].Value.Trim();
+ }
}
+
+
}
catch(Exception ex)
{