mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using Remotely.ScreenCast.Core.Interfaces;
|
|
using Remotely.ScreenCast.Core.Services;
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
|
|
namespace Remotely.ScreenCast.Linux.Services
|
|
{
|
|
public class ClipboardServiceLinux : IClipboardService
|
|
{
|
|
public event EventHandler<string> ClipboardTextChanged;
|
|
|
|
public void BeginWatching()
|
|
{
|
|
// Not implemented.
|
|
}
|
|
|
|
public void SetText(string clipboardText)
|
|
{
|
|
var tempPath = Path.GetTempFileName();
|
|
File.WriteAllText(tempPath, clipboardText);
|
|
try
|
|
{
|
|
var psi = new ProcessStartInfo("bash", $"-c \"cat {tempPath} | xclip -i -selection clipboard\"")
|
|
{
|
|
WindowStyle = ProcessWindowStyle.Hidden
|
|
};
|
|
var proc = Process.Start(psi);
|
|
proc.WaitForExit();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.Write(ex);
|
|
}
|
|
finally
|
|
{
|
|
File.Delete(tempPath);
|
|
}
|
|
}
|
|
}
|
|
}
|