Added wayland monitor resolution support
This commit is contained in:
parent
e8a95e5313
commit
c5e02c07b5
1
go.mod
1
go.mod
@ -10,6 +10,7 @@ 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/jackmordaunt/pcidb v1.0.1 // indirect
|
||||
github.com/jackmordaunt/wmi v1.2.4 // indirect
|
||||
|
2
go.sum
2
go.sum
@ -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/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/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
github.com/jackmordaunt/ghw v1.0.4 h1:as+COFuPuXaNQC3WqzoHS/E2JYWZU7gN8ompNTUxNxs=
|
||||
|
21
utils.go
21
utils.go
@ -3,8 +3,7 @@ package main
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"github.com/BurntSushi/xgb"
|
||||
"github.com/BurntSushi/xgb/xinerama"
|
||||
"github.com/go-gl/glfw/v3.3/glfw"
|
||||
"github.com/jackmordaunt/ghw"
|
||||
"github.com/mitchellh/go-ps"
|
||||
"github.com/moby/sys/mountinfo"
|
||||
@ -295,20 +294,16 @@ func GetDisplayProtocol() string {
|
||||
|
||||
func getMonitorResolution() []string {
|
||||
var monitors []string
|
||||
if GetDisplayProtocol() == "X11" {
|
||||
conn, err := xgb.NewConn()
|
||||
if GetDisplayProtocol() != "" {
|
||||
err := glfw.Init()
|
||||
if err != nil {
|
||||
return nil
|
||||
panic(err)
|
||||
}
|
||||
err = xinerama.Init(conn)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
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)))
|
||||
for _, monitor := range glfw.GetMonitors() {
|
||||
mode := monitor.GetVideoMode()
|
||||
monitors = append(monitors, fmt.Sprintf("%dx%d %dHz", mode.Width, mode.Height, mode.RefreshRate))
|
||||
}
|
||||
defer glfw.Terminate()
|
||||
}
|
||||
return monitors
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user