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()
	}
}
