screenresolution

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2024 License: MIT, MIT Imports: 2 Imported by: 0

README

screenresolution

screenresolution is a simple, cross-platform Go package library used to detect the current screen resolution. It follows the UNIX philosophy of doing one thing and doing it well.

It supports Windows, Linux and MaxOS.

Example

package main

import (
	"fmt"
	"os"

	"github.com/fstanis/screenresolution"
)

func main() {
	resolution := screenresolution.GetPrimary()
	if resolution == "" {
		fmt.Println("failed to get screen resolution")
		os.Exit(1)
	}
	fmt.Println(resolution)
}

Limitations

screenresolution can only get the resolution from the default (primary) display. A future update will add support for getting the resolutions of all attached displays.

Dependencies

On Linux, libx11-dev is required.

sudo apt-get install libx11-dev

Documentation

Overview

Package screenresolution is used to retrieve the current screen resolution.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resolution

type Resolution struct {
	Width, Height int
}

Resolution represents the resolution of a single screen.

func GetPrimary

func GetPrimary() *Resolution

GetPrimary returns the current screen resolution of the primary display.

Example
fmt.Println(GetPrimary().String())
Output:

1024x768

func (*Resolution) String

func (r *Resolution) String() string

Jump to

Keyboard shortcuts

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