Added wayland monitor resolution support

This commit is contained in:
EnumDev 2024-08-23 14:48:52 +03:00
parent e8a95e5313
commit c5e02c07b5
3 changed files with 11 additions and 13 deletions

1
go.mod
View File

@ -10,6 +10,7 @@ require (
) )
require ( require (
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a // indirect
github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-ole/go-ole v1.2.6 // indirect
github.com/jackmordaunt/pcidb v1.0.1 // indirect github.com/jackmordaunt/pcidb v1.0.1 // indirect
github.com/jackmordaunt/wmi v1.2.4 // indirect github.com/jackmordaunt/wmi v1.2.4 // indirect

2
go.sum
View File

@ -1,5 +1,7 @@
github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc h1:7D+Bh06CRPCJO3gr2F7h1sriovOZ8BMhca2Rg85c2nk= github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc h1:7D+Bh06CRPCJO3gr2F7h1sriovOZ8BMhca2Rg85c2nk=
github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a h1:vxnBhFDDT+xzxf1jTJKMKZw3H0swfWk9RpWbBbDK5+0=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/jackmordaunt/ghw v1.0.4 h1:as+COFuPuXaNQC3WqzoHS/E2JYWZU7gN8ompNTUxNxs= github.com/jackmordaunt/ghw v1.0.4 h1:as+COFuPuXaNQC3WqzoHS/E2JYWZU7gN8ompNTUxNxs=

View File

@ -3,8 +3,7 @@ package main
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"github.com/BurntSushi/xgb" "github.com/go-gl/glfw/v3.3/glfw"
"github.com/BurntSushi/xgb/xinerama"
"github.com/jackmordaunt/ghw" "github.com/jackmordaunt/ghw"
"github.com/mitchellh/go-ps" "github.com/mitchellh/go-ps"
"github.com/moby/sys/mountinfo" "github.com/moby/sys/mountinfo"
@ -295,20 +294,16 @@ func GetDisplayProtocol() string {
func getMonitorResolution() []string { func getMonitorResolution() []string {
var monitors []string var monitors []string
if GetDisplayProtocol() == "X11" { if GetDisplayProtocol() != "" {
conn, err := xgb.NewConn() err := glfw.Init()
if err != nil { if err != nil {
return nil panic(err)
} }
err = xinerama.Init(conn) for _, monitor := range glfw.GetMonitors() {
if err != nil { mode := monitor.GetVideoMode()
return nil monitors = append(monitors, fmt.Sprintf("%dx%d %dHz", mode.Width, mode.Height, mode.RefreshRate))
}
reply, _ := xinerama.QueryScreens(conn).Reply()
conn.Close()
for _, screen := range reply.ScreenInfo {
monitors = append(monitors, strconv.Itoa(int(screen.Width))+"x"+strconv.Itoa(int(screen.Height)))
} }
defer glfw.Terminate()
} }
return monitors return monitors
} }