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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
⌂ 换网址