Skip to content

Commit

Permalink
采集Linux桌面系统的分辨率,但是服务后台运行时采集失败
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed May 5, 2024
1 parent 3e4e858 commit 72199f7
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Stardust/StarClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public NodeInfo GetNodeInfo()
if (Runtime.Windows) FixGdi(di);
#endif

if (Runtime.Linux) di.MaxOpenFiles = Execute("bash", "-c \"ulimit -n\"")?.Trim().ToInt() ?? 0;
if (Runtime.Linux) FixOnLinux(di);

return di;
}
Expand Down Expand Up @@ -323,6 +323,22 @@ public static void FixGdi(NodeInfo di)
}
#endif

private static void FixOnLinux(NodeInfo di)
{
di.MaxOpenFiles = Execute("bash", "-c \"ulimit -n\"")?.Trim().ToInt() ?? 0;

var xrandr = Execute("xrandr", "-q");
if (!xrandr.IsNullOrEmpty())
{
var current = xrandr.Substring("current", ",").Trim();
if (!current.IsNullOrEmpty())
{
var ss = current.SplitAsInt("x");
if (ss.Length >= 2) di.Resolution = $"{ss[0]}*{ss[1]}";
}
}
}

/// <summary>获取驱动器信息</summary>
/// <returns></returns>
public static IList<DriveInfo> GetDrives()
Expand Down

0 comments on commit 72199f7

Please sign in to comment.