Skip to content

Commit

Permalink
Get Ubuntu who information differently.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Mar 11, 2020
1 parent 538f79d commit 437569e
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions Agent/Services/AppLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ private int StartLinuxScreenCaster(string args)

var processes = OSUtils.StartProcessWithResults("ps", "-eaf").Split(Environment.NewLine);
var xorgLine = processes.FirstOrDefault(x => x.Contains("xorg"));
Logger.Write($"Xorg Line: {xorgLine}");
var xorgSplit = xorgLine.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList();
var auth = xorgSplit[xorgSplit.IndexOf("-auth") + 1];
if (!string.IsNullOrWhiteSpace(auth))
Expand All @@ -175,17 +174,27 @@ private int StartLinuxScreenCaster(string args)
}

var display = ":0";
var whoString = OSUtils.StartProcessWithResults("who", "")?.Trim();
var whoString = OSUtils.StartProcessWithResults("w", "-h")?.Trim();
var username = string.Empty;

if (!string.IsNullOrWhiteSpace(whoString))
{
var whoLine = whoString.Split('\n', StringSplitOptions.RemoveEmptyEntries).First();
var whoSplit = whoLine.Split(' ', StringSplitOptions.RemoveEmptyEntries);
username = whoSplit[0];
display = whoSplit.Last().Trim('(').Trim(')');
xauthority = $"/home/{username}/.Xauthority";
args = $"-u {username} {args}";
try
{
var whoLine = whoString
.Split('\n', StringSplitOptions.RemoveEmptyEntries)
.First();

var whoSplit = whoLine.Split(' ', StringSplitOptions.RemoveEmptyEntries);
username = whoSplit[0];
display = whoSplit[2];
xauthority = $"/home/{username}/.Xauthority";
args = $"-u {username} {args}";
}
catch (Exception ex)
{
Logger.Write(ex);
}
}

var psi = new ProcessStartInfo()
Expand Down

0 comments on commit 437569e

Please sign in to comment.