Skip to content

Commit

Permalink
cleanup linux socializer upload window
Browse files Browse the repository at this point in the history
  • Loading branch information
rbreesems committed May 24, 2024
1 parent 7e140fb commit 6d6bf5c
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/ghosts.client.linux/Infrastructure/LinuxSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private static void ErrorHandler(object sendingProcess, DataReceivedEventArgs ou
return;
}

private void ExecuteBashCommand(string id, string command)
private string ExecuteBashCommand(string id, string command)
{
var escapedArgs = command.Replace("\"", "\\\"");

Expand All @@ -66,21 +66,27 @@ private void ExecuteBashCommand(string id, string command)

p.WaitForExit();
Log.Trace($"Social:: Bash command output: {Result}");
return Result;
}

public void AttachFile()
{
try {
string cmd = $"xdotool search -name '{windowTitle}' windowfocus type '{filename}' ";
ExecuteBashCommand(id, cmd);
Thread.Sleep(800);
Thread.Sleep(2000);
cmd = $"xdotool search -name '{windowTitle}' windowfocus key KP_Enter";
ExecuteBashCommand(id, cmd);
Thread.Sleep(500);
// send this close in case the previous commands failed. If the window is closed will have no effect
cmd = $"xdotool search -name '{windowTitle}' windowfocus key alt+c";
ExecuteBashCommand(id, cmd);
Thread.Sleep(500);
Thread.Sleep(2000);
// Check if the window has closed
cmd = $"xdotool search -name '{windowTitle}'";
string result = ExecuteBashCommand(id, cmd);
if (result != "") {
// close the window
cmd = $"xdotool search -name '{windowTitle}' windowfocus key alt+c";
ExecuteBashCommand(id, cmd);
Thread.Sleep(500);
}
return;
}
catch (Exception e) {
Expand Down

0 comments on commit 6d6bf5c

Please sign in to comment.