aboutsummaryrefslogtreecommitdiff
path: root/src/GetWindows.cs
diff options
context:
space:
mode:
authorDemonKingSwarn <rockingswarn@gmail.com>2026-04-19 23:04:46 +0530
committerDemonKingSwarn <rockingswarn@gmail.com>2026-04-19 23:04:46 +0530
commitdacfac59f1cf60df7fc80a21cb7f3d63843aa591 (patch)
tree281cb3697d5eaf873100101290002b2ce61bea93 /src/GetWindows.cs
parent0dc53f2c6a5093344e6188b5510d1505cd3a4a2a (diff)
downloadhypr-wellbeing-dacfac59f1cf60df7fc80a21cb7f3d63843aa591.zip
hypr-wellbeing-dacfac59f1cf60df7fc80a21cb7f3d63843aa591.tar.gz
chore: made sure the binary is static
Diffstat (limited to 'src/GetWindows.cs')
-rw-r--r--src/GetWindows.cs91
1 files changed, 37 insertions, 54 deletions
diff --git a/src/GetWindows.cs b/src/GetWindows.cs
index 0508a88..44e7109 100644
--- a/src/GetWindows.cs
+++ b/src/GetWindows.cs
@@ -5,7 +5,6 @@ namespace hyprwatch.Window
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Text.RegularExpressions;
- using Newtonsoft.Json;
public partial class GetWindows
{
@@ -14,75 +13,59 @@ namespace hyprwatch.Window
string desktopEnv = Environment.GetEnvironmentVariable("XDG_CURRENT_DESKTOP");
string homeDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
string? activeWindow = null;
- string? os = null;
string configFile = Path.Combine(homeDir, ".config", "hypr-wellbeing", "config.json");
- if(File.Exists(configFile))
- {
- string content = File.ReadAllText(configFile);
- var config = JsonConvert.DeserializeObject<Dictionary<string, string>>(content);
-
- os = config["os"];
- }
- else
- {
- os = "Linux";
- }
-
- if(os == "Linux")
- {
- try {
- Process process = new Process();
- process.StartInfo = new ProcessStartInfo();
-
- process.StartInfo.RedirectStandardOutput = true;
- process.StartInfo.UseShellExecute = false;
- process.StartInfo.CreateNoWindow = true;
+ try {
+ Process process = new Process();
+ process.StartInfo = new ProcessStartInfo();
+
+ process.StartInfo.RedirectStandardOutput = true;
+ process.StartInfo.UseShellExecute = false;
+ process.StartInfo.CreateNoWindow = true;
- if(desktopEnv == "Hyprland")
- {
- process.StartInfo.FileName = "hyprctl";
- process.StartInfo.Arguments = "activewindow";
- }
- else if(desktopEnv == "niri")
- {
- process.StartInfo.FileName = "niri";
- process.StartInfo.Arguments = "msg focused-window";
- }
-
- process.Start();
-
- string output = process.StandardOutput.ReadToEnd();
- process.WaitForExit();
+ if(desktopEnv == "Hyprland")
+ {
+ process.StartInfo.FileName = "hyprctl";
+ process.StartInfo.Arguments = "activewindow";
+ }
+ else if(desktopEnv == "niri")
+ {
+ process.StartInfo.FileName = "niri";
+ process.StartInfo.Arguments = "msg focused-window";
+ }
- var classMatch = ClassRegex().Match(output);
+ process.Start();
- if(desktopEnv == "niri")
- {
- var match = Regex.Match(output, "App ID:\\s+\"([^\"]+)\"");
- if(match.Success)
- {
- activeWindow = match.Groups[1].Value.Trim();
- }
- }
+ string output = process.StandardOutput.ReadToEnd();
+ process.WaitForExit();
+ var classMatch = ClassRegex().Match(output);
- if(desktopEnv == "Hyprland")
+ if(desktopEnv == "niri")
{
- if(classMatch.Success)
+ var match = Regex.Match(output, "App ID:\\s+\"([^\"]+)\"");
+ if(match.Success)
{
- activeWindow = classMatch.Groups[1].Value.Trim();
+ activeWindow = match.Groups[1].Value.Trim();
}
- }
+ }
- }
- catch(Exception ex)
+ if(desktopEnv == "Hyprland")
{
- Console.WriteLine(ex.Message);
+ if(classMatch.Success)
+ {
+ activeWindow = classMatch.Groups[1].Value.Trim();
+ }
}
+
+
+ }
+ catch(Exception ex)
+ {
+ Console.WriteLine(ex.Message);
}
if(activeWindow == null)