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

Using clipboard trough ssh #19

Closed
microo8 opened this issue Jan 22, 2022 · 9 comments · Fixed by #18
Closed

Using clipboard trough ssh #19

microo8 opened this issue Jan 22, 2022 · 9 comments · Fixed by #18
Labels
enhancement New feature or request

Comments

@microo8
Copy link
Contributor

microo8 commented Jan 22, 2022

I have a TUI application, which could potencially run trough ssh.
It's a rss reader with sixel images: https://sr.ht/~ghost08/photon
There are keybindings to copy the rss item's link, or the item's image, for which I use the golang-design/clipboard library.

But when I run it trough ssh it just panics this:

panic: Failed to initialize the X11 display, and the clipboard package
will not work properly. Install the following dependency may help:

	apt install -y libx11-dev

If the clipboard package is in an environment without a frame buffer,
such as a cloud server, it may also be necessary to install xvfb:

	apt install -y xvfb

and initialize a virtual frame buffer:

	Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
	export DISPLAY=:99.0

Then this package should be ready to use.


goroutine 1 [running]:
golang.design/x/clipboard.init.0()
	golang.design/x/[email protected]/clipboard_linux.go:65 +0x4b

Is there a way to ignore the missing display and don't panic?
I know that trough ssh clipboard will not work, but that's ok.

@changkun
Copy link
Member

Have you initialized the virtual frame buffer?

This

$ Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
$ export DISPLAY=:99.0

may help.

@microo8
Copy link
Contributor Author

microo8 commented Jan 22, 2022 via email

@changkun
Copy link
Member

Then we can't use the package anymore. Clipboard is stictly depends on the desktop environment. Currently it supports X11 hence libx11-dev is required.

#6 speaks about Wayland support but it would also require another dependency for Wayland.

@microo8
Copy link
Contributor Author

microo8 commented Jan 22, 2022 via email

@changkun
Copy link
Member

That's a good argument. Does returning an error help your use case?

func Read(t Format) ([]byte, error)
func Watch(ctx context.Context, t Format) (<-chan []byte, error)
func Write(t Format, buf []byte) (<-chan struct{}, error)

Then this will be a breaking change.

@microo8
Copy link
Contributor Author

microo8 commented Jan 22, 2022 via email

@changkun
Copy link
Member

That's a bit tricky. I like the idea of Init but not entirely sure if this is how we should proceed. The current Read/Write/Watch in fact ignored errors and does not return it to its callee. Returning errors might be the most proper way, but would also make all user code a bit ugly.

@changkun changkun mentioned this issue Jan 22, 2022
@changkun changkun added the enhancement New feature or request label Jan 22, 2022
@changkun
Copy link
Member

This is now avaliable at v0.6.0

@microo8
Copy link
Contributor Author

microo8 commented Jan 23, 2022 via email

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

Successfully merging a pull request may close this issue.

2 participants