https://github.com/jasonlovesdoggo/displayindex
A cross-platform Go package to detect which display contains the cursor.
https://github.com/jasonlovesdoggo/displayindex
active-display cross-platform cursor display go golang library linux macos windows
Last synced: 3 months ago
JSON representation
A cross-platform Go package to detect which display contains the cursor.
- Host: GitHub
- URL: https://github.com/jasonlovesdoggo/displayindex
- Owner: JasonLovesDoggo
- License: mit
- Created: 2025-02-01T00:36:00.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-02-05T03:49:07.000Z (4 months ago)
- Last Synced: 2025-03-19T09:02:18.890Z (3 months ago)
- Topics: active-display, cross-platform, cursor, display, go, golang, library, linux, macos, windows
- Language: Go
- Homepage: https://pkg.go.dev/github.com/jasonlovesdoggo/displayindex
- Size: 26.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Go Display Index
[](https://github.com/jasonlovesdoggo/displayindex/actions)
[](https://goreportcard.com/report/github.com/jasonlovesdoggo/displayindex)
[](https://pkg.go.dev/github.com/jasonlovesdoggo/displayindex)A cross-platform Go package to detect which display contains the cursor.
## Features
- Supports Windows, macOS, and Linux
- Simple API## Installation
```bash
go get github.com/jasonlovesdoggo/displayindex
```## Usage
```go
package mainimport (
"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
```bash
sudo apt-get install libx11-dev
```