fix hyprclt & mapping output->monitor

This commit is contained in:
piotr
2024-09-22 13:44:02 +02:00
parent 86c92328cd
commit 1015f4c48f

View File

@@ -689,13 +689,8 @@ func mapOutputs() (map[string]*gdk.Monitor, error) {
num := display.GetNMonitors() num := display.GetNMonitors()
for i := 0; i < num; i++ { for i := 0; i < num; i++ {
mon, _ := display.GetMonitor(i) mon, _ := display.GetMonitor(i)
geometry := mon.GetGeometry() output := hyprlandMonitors[i]
// assign output to monitor on the basis of the same x, y coordinates result[output.Name] = mon
for _, output := range hyprlandMonitors {
if int(output.X) == geometry.GetX() && int(output.Y) == geometry.GetY() {
result[output.Name] = mon
}
}
} }
} else { } else {
return nil, err return nil, err
@@ -723,13 +718,8 @@ func mapOutputs() (map[string]*gdk.Monitor, error) {
num := display.GetNMonitors() num := display.GetNMonitors()
for i := 0; i < num; i++ { for i := 0; i < num; i++ {
mon, _ := display.GetMonitor(i) mon, _ := display.GetMonitor(i)
geometry := mon.GetGeometry() output := outputs[i]
// assign output to monitor on the basis of the same x, y coordinates result[output.Name] = mon
for _, output := range outputs {
if int(output.Rect.X) == geometry.GetX() && int(output.Rect.Y) == geometry.GetY() {
result[output.Name] = mon
}
}
} }
} else { } else {
return nil, errors.New("output assignment only supported on sway and Hyprland") return nil, errors.New("output assignment only supported on sway and Hyprland")
@@ -756,7 +746,15 @@ func substring(s string, start int, end int) string {
func hyprctl(cmd string) ([]byte, error) { func hyprctl(cmd string) ([]byte, error) {
his := os.Getenv("HYPRLAND_INSTANCE_SIGNATURE") his := os.Getenv("HYPRLAND_INSTANCE_SIGNATURE")
socketFile := fmt.Sprintf("/tmp/hypr/%s/.socket.sock", his) xdgRuntimeDir := os.Getenv("XDG_RUNTIME_DIR")
hyprDir := ""
if xdgRuntimeDir != "" {
hyprDir = fmt.Sprintf("%s/hypr", xdgRuntimeDir)
} else {
hyprDir = "/tmp/hypr"
}
socketFile := fmt.Sprintf("%s/%s/.socket.sock", hyprDir, his)
conn, err := net.Dial("unix", socketFile) conn, err := net.Dial("unix", socketFile)
if err != nil { if err != nil {
return nil, err return nil, err