displayindex

package module
v0.0.0-...-c0ed088 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2025 License: MIT Imports: 3 Imported by: 0

README

Go Display Index

CI Status Go Report Card Go Reference

A cross-platform Go package to detect which display contains the cursor.

Features

  • Supports Windows, macOS, and Linux
  • Simple API

Installation

go get github.com/jasonlovesdoggo/displayindex

Usage

package main

import (
	"fmt"
	"github.com/jasonlovesdoggo/displayindex"
	"github.com/kbinani/screenshot"
)

func main() {
	index, err := displayindex.CurrentDisplayIndex()
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	fmt.Printf("Cursor is on display %d\n", index)
	img, err := screenshot.CaptureDisplay(index)  /* Example how you can use the index*/
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
	// Do something with the image
}

Requirements

  • Linux: Requires X11 development libraries
    sudo apt-get install libx11-dev
    

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentDisplayIndex

func CurrentDisplayIndex() (int, error)

CurrentDisplayIndex returns the display index containing the cursor (0-based) Returns -1 and error if cursor not found on any display

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL