CopyText / TextCopy

A cross platform package to copy text to and from the clipboard.
MIT License
513 stars 41 forks source link

Linux - Can't work properly on GitHub Codespaces #739

Closed YYHEggEgg closed 8 months ago

YYHEggEgg commented 1 year ago

Info

Framework (tested): net6.0, net7.0
Package version: 6.2.1
Environment: GitHub Codespaces, 4 cores, 16 GB RAM, 32 GB storage

Minimum reproduce steps

  1. Set up a codespace with C# toolkits (can be automatically configured when creating codespace on any C# repos).

  2. Wait for setting up, and run the following commands in bash:

    dotnet new console -n TestTextCopy
    cd ./TestTextCopy
    dotnet add package TextCopy
  3. Replace Program.cs with the following code:

    using TextCopy;
    
    string text = "Hello World!";
    ClipboardService.SetText(text);
  4. dotnet run.

Result

Unhandled exception. System.Exception: Could not execute process. Command line: bash -c "cat /tmp/tmp8us3aw.tmp | xsel -i --clipboard ".
Output: 

Error: xsel: Can't open display: (null)
: Inappropriate ioctl for device

   at BashRunner.Run(String commandLine) in /_/src/TextCopy/BashRunner.cs:line 42
   at LinuxClipboard.InnerSetText(String tempFileName) in /_/src/TextCopy/LinuxClipboard_2.1.cs:line 42
   at LinuxClipboard.SetText(String text) in /_/src/TextCopy/LinuxClipboard_2.1.cs:line 29
   at TextCopy.ClipboardService.SetText(String text) in /_/src/TextCopy/ClipboardService.cs:line 61
   at Program.<Main>$(String[] args) in /workspaces/[ExampleRepo]/TestTextCopy/Program.cs:line 4
SimonCropp commented 1 year ago

happy to accept a pull request that fixes this