Skip to content

Commit 155b185

Browse files
committed
linux: improve error message
Fixes #10
1 parent e75e871 commit 155b185

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

clipboard_linux.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,28 @@ import (
3939
"unsafe"
4040
)
4141

42+
const errmsg = `Failed to initialize the X11 display, and the clipboard package
43+
will not work properly. Install the following dependency may help:
44+
45+
apt install -y libx11-dev
46+
47+
If the clipboard package is in an environment without a frame buffer,
48+
such as a cloud server, it may also be necessary to install xvfb:
49+
50+
apt install -y xvfb
51+
52+
and initialize a virtual frame buffer:
53+
54+
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
55+
export DISPLAY=:99.0
56+
57+
Then this package should be ready to use.
58+
`
59+
4260
func init() {
4361
ok := C.clipboard_test()
4462
if ok < 0 {
45-
panic(`cannot use this package, failed to initialize x11 display, maybe try install:
46-
47-
apt install -y libx11-dev
48-
`)
63+
panic(errmsg)
4964
}
5065
}
5166

0 commit comments

Comments
 (0)