Coder Social home page Coder Social logo

clipboard's People

Contributors

andriikushch avatar anthonyraymond avatar aral avatar atotto avatar dagoof avatar dncohen avatar driusan avatar ewoutp avatar ewxrjk avatar henesy avatar hymkor avatar idawes avatar ikalnytskyi avatar justinjudd avatar philpennock avatar robertknight avatar schnouki avatar svent avatar uvelichitel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clipboard's Issues

Go 1.3 Copy stack growth error

I'm getting the following error using the following one liner:

clipboard.WriteAll("test")
fatal error: runtime: stack growth during syscall

runtime stack:
runtime.throw(0x4b9ba50)
    /Users/jeffrey/.go_root/src/pkg/runtime/panic.c:520 +0x69
runtime.newstack()
    /Users/jeffrey/.go_root/src/pkg/runtime/stack.c:739 +0x7e3
runtime.morestack()
    /Users/jeffrey/.go_root/src/pkg/runtime/asm_amd64.s:228 +0x61

goroutine 16 [stack growth]:
syscall.Syscall6(0x7, 0x92ff, 0x6d77664, 0x0, 0xc209433680, 0x0, 0x0, 0x408a169, 0x60, 0xc209433680)
    /Users/jeffrey/.go_root/src/pkg/syscall/asm_darwin_amd64.s:44 +0x5 fp=0x6d775c8 sp=0x6d775c0
syscall.wait4(0x92ff, 0x6d77664, 0x0, 0xc209433680, 0x409250b, 0x0, 0x0)
    /Users/jeffrey/.go_root/src/pkg/syscall/zsyscall_darwin_amd64.go:32 +0x7d fp=0x6d77628 sp=0x6d775c8
syscall.Wait4(0x92ff, 0x6d776ac, 0x0, 0xc209433680, 0x68ad6b8, 0x0, 0x0)
    /Users/jeffrey/.go_root/src/pkg/syscall/syscall_bsd.go:129 +0x64 fp=0x6d77670 sp=0x6d77628
os.(*Process).wait(0xc2099913a0, 0x46439e0, 0x0, 0x0)
    /Users/jeffrey/.go_root/src/pkg/os/exec_unix.go:22 +0xfe fp=0x6d77718 sp=0x6d77670
os.(*Process).Wait(0xc2099913a0, 0x0, 0x0, 0x0)
    /Users/jeffrey/.go_root/src/pkg/os/doc.go:45 +0x39 fp=0x6d77740 sp=0x6d77718
os/exec.(*Cmd).Wait(0xc20920b2c0, 0x0, 0x0)
    /Users/jeffrey/.go_root/src/pkg/os/exec/exec.go:357 +0x1db fp=0x6d77818 sp=0x6d77740
github.com/atotto/clipboard.writeAll(0x4744700, 0x4, 0x0, 0x0)
    /Users/jeffrey/go/src/github.com/atotto/clipboard/clipboard_darwin.go:51 +0x1aa fp=0x6d778b0 sp=0x6d77818
github.com/atotto/clipboard.WriteAll(0x4744700, 0x4, 0x0, 0x0)
Mac OS X 10.10
go version go1.3 darwin/amd64

Stdout already set error in macos

I'm using osx 10.9.5, and following snippet gives a strange output:

package main

import (
    "fmt";
    "github.com/robertknight/clipboard";
    "time";
)

func main() {
    for {
        s, err := clipboard.ReadAll();
        if err != nil {
            fmt.Printf("%s\n", err);
        }
        fmt.Printf("%s\n", s);
        time.Sleep(1000 * time.Millisecond);
    }
}

it prints:
whatever in clipboard
exec: Stdout already set
exec: Stdout already set
...

how can I fix this?

xsel and xcopy are X11-specific, not Linux-specific

xsel and xcopy are both POSIX programs and run perfectly on any Unix system, including OpenBSD, NetBSD and FreeBSD. Not just Linux.

Instead of being Linux-specific, contents of clipboard_linux.go should be provided by default as a fallback.

Move scary $PATH clipboard utility scan out of init() to as-needed

A concerned user reported that one of our security tools was scanning for clipboard programs:

694472 newfstatat(AT_FDCWD, "/home/n/.go/bin/xclip", 0xc0001ab968, 0) = -1 ENOENT (No such file or directory)
694472 newfstatat(AT_FDCWD, "/home/n/.go/bin/xclip", 0xc0002fc448, 0) = -1 ENOENT (No such file or directory)
694472 newfstatat(AT_FDCWD, "/home/n/.local/bin/xclip", 0xc0002fc6b8, 0) = -1 ENOENT (No such file or directory)
694472 newfstatat(AT_FDCWD, "/home/n/bin/xclip", 0xc0002fc788, 0) = -1 ENOENT (No such file or directory)
694472 newfstatat(AT_FDCWD, "/home/n/.cargo/bin/xclip", 0xc0002fc858, 0) = -1 ENOENT (No such file or directory)
694472 newfstatat(AT_FDCWD, "/usr/local/bin/xclip", 0xc0002fc928, 0) = -1 ENOENT (No such file or directory)
694472 newfstatat(AT_FDCWD, "/usr/local/sbin/xclip", 0xc0002fc9f8, 0) = -1 ENOENT (No such file or directory)
694472 newfstatat(AT_FDCWD, "/usr/bin/xclip", 0xc0002fcac8, 0) = -1 ENOENT (No such file or directory)
694472 newfstatat(AT_FDCWD, "/usr/sbin/xclip", 0xc0002fcb98, 0) = -1 ENOENT (No such file or directory)
694472 newfstatat(AT_FDCWD, "/home/n/.go/bin/xsel", 0xc0002fcc68, 0) = -1 ENOENT (No such file or directory)

Since our program does nothing with the clipboard, I was concerned that this might be a supply-chain security attack, so we dug into the dependencies and found this library:

$ go mod graph | egrep -i 'clip|chirp'
x.dev/xctl github.com/atotto/[email protected]
github.com/charmbracelet/[email protected] github.com/atotto/[email protected]

On investigation, we saw that the clipboard library causes a filesystem scan to occur on import:

https://github.com/atotto/clipboard/blob/master/clipboard_unix.go#L51-L97

It would be preferable if this filesystem scan was done as needed rather than at import, not only for binary startup performance but because it's less scary for users when they see this in system call traces.

PS - thank you for the fantastic robust library you have put together.

LF

Hi,

How do I copy without CRLF to clipboard? What should I change in the code?

Thanks in advance.

Breaks after certain time of using continuosly

I created an application that reads the content of the clipboard every second to synchronize several clipboards.
After some time running, the application will become unable to read content from the clipboard and will return this error: fork/exec /usr/bin/pbpaste: too many open files
I have tested it both in macOS and Ubuntu (The message in Ubuntu is the same with different executable and takes longer to appear).

Data Passthrough?

echo "testing" | gocopy

Works perfectly well, however, it doesn't return data to stdout, which should IMO be the default behavior. If you want to supress output, then pass a flag;

> echo "testing" | gocopy
"testing"

> echo "testing" | gocopy -q

> 

Since gocopy slurps all input, even using tee as a workaround doesn't work.

> echo "testing" | tee | gocopy

>

Memory leak if SetClipboardData returns error?

I'm not entirely familiar with the Windows API, but from the description of SetClipboardData() it appears that ownership of the memory object allocated in WriteAll() is not transferred to the system if SetClipboardData fails, so it would be up to WriteAll() to free it.

Support file form clipboard

Support of files copied from system

Like, copy a few files from windows explorer and it would give you the name of these files
I can probably build the windows version, but no idea for the other platforms

clear clipboard Error in clipboard_windows.go

problem

When I repeatedly read the clipboard and then clear the clipboard, the clipping operation fails and the content cannot be read.

solved

I guessed that the problem might be that I used the writeAll function and passed in an empty string, so I added a new function: clearAll

func clearAll() error {
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	err := waitOpenClipboard()
	if err != nil {
		return err
	}

	r, _, err := emptyClipboard.Call(0)
	_, _, _ = closeClipboard.Call()
	if r == 0 {
		return err
	}
	return nil
}

it doesn't work on headless chrome

i am using it alongside another package for automating browser testing, and it works will in ordinary mode but if i tried to run my tests in headless mode it don't do any pasting
and it's blocking me for using docker for my tests also

no clipboard text while in Windows service

The logic of my progrom is read texts from the clipboard and send them to my server

And clipboard.ReadAll() works fine when I run the .exe in CMD

But when I tried to run it as a service, clipboard.ReadAll() returns an error like: The operation completed successfully

Are there any solutions for this? Thank you.

Add support for clearing the clipboard

Hi! I've used this little lib in one of my projects and it works great! Thanks for creating this :)

But I would like to make a feature request: add support for clearing the clipboard.

For example, in Linux with xsel you just need to call xsel -c.

Not sure about Mac/Windows, but hope it's easy to do as well.

My usecase is that I want to copy sensitive information to the clipboard for a short period of time.

On Windows, WriteAll() seems to write not all charactors

I wrote a sample code like below.

package main

import "fmt"
import "github.com/atotto/clipboard"

func main(){
    clipboard.WriteAll("hogehoge")
    text,err := clipboard.ReadAll()
    if err == nil {
        fmt.Printf("[%s]\n",text)
    }else{
        fmt.Println(err)
    }
}

Run it on Windows 7

[C:tstClip]
$ go run tstClip.go
[hogeho]
[C:tstClip]

I expected that [hogehoge] is printed.
I found ReadAll() has no problem on the other test.

Did I do something wrong?

(日本語の方がいいでしょうか?)

Tag releases to make project godep friendly.

Hello. Could you please tag releases so that dep can use that information to make builds more reproducible?

Check https://github.com/golang/dep.

Currently, using your project with godep I get this in the toml file:

[[constraint]]
  branch = "master"
  name = "github.com/atotto/clipboard"

With a tag, it would constrain the dependency to that tag.

Windows Subsystem for Linux support

It would be awesome if executing clip.exe was used as an additional fallback on Linux. That way, in WSL environments where xclip and xsel are not installed, text could be copied to the Windows clipboard. Specifically, I'm trying to use gopass (which uses this library) under WSL.

In cases where someone is running an X server on WSL, the situation gets complicated unfortunately.

[Linux Mint] Dysfunctional Copy and Paste. Relates to another project

Issue being a dysfunctional copy and paste after doing "go get github.com/atotto/clipboard". Command does not exist and does not work.
issuing "cat README.md|gocopy" leads to "gocopy: command not found"

Pointed here by a dev of another project as a possible cause of the issue, to see the issue I had there see the following link:
Bios-Marcel/cordless#313

Will provide more detail if requested.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.