init commit
This commit is contained in:
39
internal/clipboard/detector.go
Normal file
39
internal/clipboard/detector.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package clipboard
|
||||
|
||||
import "os"
|
||||
|
||||
type DisplayServer int
|
||||
|
||||
const (
|
||||
DisplayServerUnknown DisplayServer = iota
|
||||
DisplayServerX11
|
||||
DisplayServerWayland
|
||||
)
|
||||
|
||||
// Detect returns the current display server type
|
||||
func Detect() DisplayServer {
|
||||
// Check for Wayland first
|
||||
if os.Getenv("WAYLAND_DISPLAY") != "" {
|
||||
return DisplayServerWayland
|
||||
}
|
||||
|
||||
// Check for X11
|
||||
if os.Getenv("DISPLAY") != "" {
|
||||
return DisplayServerX11
|
||||
}
|
||||
|
||||
return DisplayServerUnknown
|
||||
}
|
||||
|
||||
// New creates a clipboard implementation for the current display server
|
||||
func New() (Clipboard, error) {
|
||||
switch Detect() {
|
||||
case DisplayServerWayland:
|
||||
return NewWayland()
|
||||
case DisplayServerX11:
|
||||
return NewX11()
|
||||
default:
|
||||
// Try X11 as fallback
|
||||
return NewX11()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user