Skip to content

Commit

Permalink
Adding xclip as a clipboard fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
daonb committed Apr 11, 2024
1 parent 980db85 commit 5724864
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
13 changes: 7 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ and the release workflow reads it to set github's release notes.


## Unreleased
This versio includes breaking changes the peers library.

This version includes breaking changes in the peers library.

### Added

- webexec paste command to print the client's clipboard to standard output
- webexec copy command to copy standard input to the client's clipboard
- ack in the `timeouts` section of the configuration file
- paste subcommand to print the client's clipboard to standard output
- copy subcommand to copy standard input to the client's clipboard
- an ack value in the `timeouts` section of the configuration file

### Added
### Fixed

- when ice gathering timeouts, the agent will work with the gathered candidates
- not aboring connection attempts when ice gathering timeouts

## [1.3.2] 2024-2-25

Expand Down
26 changes: 22 additions & 4 deletions sock.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,16 +346,29 @@ func (s *sockServer) handleOffer(w http.ResponseWriter, r *http.Request) {
}
}
func readClipboard() ([]byte, error) {
var cmd *exec.Cmd
var (
cmd *exec.Cmd
ret []byte
err error
)

switch runtime.GOOS {
case "darwin":
cmd = exec.Command("pbpaste")
ret, err = cmd.Output()
case "linux":
cmd = exec.Command("xsel", "--clipboard", "--output")
ret, err = cmd.Output()
if err != nil {
if strings.Contains(err.Error(), "not found") {
cmd = exec.Command("xclip", "-out", "-selection", "clipboard")
ret, err = cmd.Output()
}
}
default:
return nil, fmt.Errorf("Unsupported platform %q for clipboard operations", runtime.GOOS)
err = fmt.Errorf("Unsupported platform %q for clipboard operations", runtime.GOOS)
}
return cmd.Output()
return ret, err
}

func writeClipboard(data []byte, mimeType string) error {
Expand All @@ -364,7 +377,12 @@ func writeClipboard(data []byte, mimeType string) error {
case "darwin":
cmd = exec.Command("pbcopy")
case "linux":
cmd = exec.Command("xsel", "--clipboard", "--input")
_, err := exec.LookPath("xsel")
if err == nil {
cmd = exec.Command("xsel", "--clipboard", "--input")
} else {
cmd = exec.Command("xclip", "-selection", "clipboard")
}
default:
return fmt.Errorf("unsupported platform for clipboard operations")
}
Expand Down

0 comments on commit 5724864

Please sign in to comment.