Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove need for xsel/xclip for lemonade client #18

Open
ninrod opened this issue Jun 9, 2016 · 17 comments
Open

remove need for xsel/xclip for lemonade client #18

ninrod opened this issue Jun 9, 2016 · 17 comments

Comments

@ninrod
Copy link

ninrod commented Jun 9, 2016

rationale:

when running a headless unix inside vagrant on a windows host, in other words, when you don't have xsel or xclip available because you don't have X server or client, I can't use lemonade.

xclip or xsel should not be needed because you have a direct connection to lemonade server via TCP.

@ninrod ninrod changed the title remove need for xsel|xclip for lemonade client remove need for xsel/xclip for lemonade client Jun 10, 2016
@Shougo
Copy link

Shougo commented Jun 11, 2016

I don't know the requirements from the code.
Can you add the error example?

@ninrod
Copy link
Author

ninrod commented Jun 18, 2016

Yes. I'll provide a sample error in a few days.

@euclio
Copy link

euclio commented Oct 21, 2016

@Shougo I am running into the same issue.

┌ euclio@apollo ~
└╌╌┄┄ ❯❯ echo "test" | lemonade copy
No clipboard utilities available. Please install xsel or xclip.
2016/10/21 12:43:00 dial tcp [::1]:2489: getsockopt: connection refused
2016/10/21 12:43:00 Fall back to localhost
exec: "xclip": executable file not found in $PATH

@Shougo
Copy link

Shougo commented Oct 22, 2016

I get it.
It seems the feature.

lemonade uses atotto/clipboard to access the clipboard.
atotto/clipboard depends on xsel or xclip.
https://github.com/atotto/clipboard/search?utf8=%E2%9C%93&q=xclip

@ninrod
Copy link
Author

ninrod commented Oct 22, 2016

@Shougo doesn't that defeat the purpose?

if I'm inside a headless docker containter I should be able to pipe a snippet of text through lemonade client and the server should be able to pick up the snippet and then use a tool to deliver the snippet to the host clipboard.

makes sense?

@Shougo
Copy link

Shougo commented Oct 22, 2016

I don't understand lemonade architecture.
@pocke Could you describe the reason?

@pocke
Copy link
Member

pocke commented Oct 23, 2016

I think the problem has two causes.

First, lemonade uses old atotto/clipboard.
The problem has been fixed in latest the library. atotto/clipboard#16

I've released lemonade with latest libraries.
https://github.com/pocke/lemonade/releases/tag/v1.1.1
Could you try the release?

Second, lemonade can't find a lemonade server.
If lemonade can't find a server, it fallbacks to localhost.

2016/10/21 12:43:00 dial tcp [::1]:2489: getsockopt: connection refused
2016/10/21 12:43:00 Fall back to localhost

The above logs show it.

Could you try to add ~/.config/lemonade.toml ? I think host setting is missing.
https://github.com/pocke/lemonade#client

@euclio
Copy link

euclio commented Oct 24, 2016

@pocke I'm still seeing the issue with version 1.1.1.

I'm now using SSH port forwarding so I am not seeing the fallback message, but I'm getting a bad exit status:

$ echo "hi" | lemonade copy
No clipboard utilities available. Please install xsel or xclip.
exit status 1

The server is receiving my commands but not acting on them.

@pocke
Copy link
Member

pocke commented Oct 25, 2016

Hmm... I think the problem is like #19 .
The error message is said by exec.Command. External command is failed.

@rafi
Copy link

rafi commented Oct 25, 2016

Regarding #19, I'm not getting No clipboard utilities available. Please install xsel or xclip., only exit status 1.

@id777
Copy link

id777 commented Dec 2, 2017

Yes, that's really sadly. What FOR lemonade client need xclip or xcel for copypaste? It's transfer data over TCP anyway, not over -X. Why I need lemonade with -X, if with -X i can share clipboard as well? For mac/linux it's easy, just create connection with ssh -X user@host. That's it, now clipboard is shareble. Without any additional stuff. On Windows same, I can just run VcXsrv and then connect with Putty with enabled -X.

So, lemonade should work like this way https://gist.github.com/dergachev/8259104 https://gist.github.com/burke/5960455. For now it's just doesn't make sence to use it, on any desktop, because same I can get with -X.

@Shougo
Copy link

Shougo commented Dec 3, 2017

@id777 You can create new PR for it.

@assaf758
Copy link

assaf758 commented Dec 3, 2017

@id777 I don't think it needs it on the client - it need it in the server/host (in order to manipulate the clipboard).
The only issue I see here is that the No clipboard utilities available message is misleading since it's not emphesizing the utility is missing on the server and not on the client

@id777
Copy link

id777 commented Dec 3, 2017

@Shougo @assaf758
my bad. See the last release, lemonade don't need anymore xclip nor xsel on remote linux server to operate with clipboard (lemonade paste, lemonade copy). Because I totally deleted xclip with xsel, connected using ssh with -R and without -X (X-window required for xsel or xclip) and lemonade works perfectly!
If you still get an error (No clipboard utilities available), that means what something wrong with connection. Try to type on remote server sudo netstat -n --tcp --listen -p and find something like tcp 0 0 127.0.0.1:2489 0.0.0.0:* LISTEN 21964/4, if it's there everything should be fine.

@Shougo
Copy link

Shougo commented Dec 4, 2017

OK. Thanks.

@mattn
Copy link
Member

mattn commented Dec 9, 2018

This can be fixed with simple change. This change make server hold fallback string per the server instance.

diff --git a/server/clipboard.go b/server/clipboard.go
index fa5ca05..0cdcfba 100644
--- a/server/clipboard.go
+++ b/server/clipboard.go
@@ -5,16 +5,27 @@ import (
 	"github.com/lemonade-command/lemonade/lemon"
 )
 
-type Clipboard struct{}
+type Clipboard struct {
+	fallback string
+}
 
-func (_ *Clipboard) Copy(text string, _ *struct{}) error {
+func (c *Clipboard) Copy(text string, _ *struct{}) error {
 	<-connCh
+	s := lemon.ConvertLineEnding(text, LineEndingOpt)
+	if !clipboard.Unsupported {
+		c.fallback = text
+		return nil
+	}
 	// Logger instance needs to be passed here somehow?
-	return clipboard.WriteAll(lemon.ConvertLineEnding(text, LineEndingOpt))
+	return clipboard.WriteAll(s)
 }
 
-func (_ *Clipboard) Paste(_ struct{}, resp *string) error {
+func (c *Clipboard) Paste(_ struct{}, resp *string) error {
 	<-connCh
+	if !clipboard.Unsupported {
+		*resp = c.fallback
+		return nil
+	}
 	t, err := clipboard.ReadAll()
 	*resp = t
 	return err

@mattn
Copy link
Member

mattn commented Mar 16, 2019

Still not. I'll look this patch in later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants